Home

mathtruncxb

Mathtruncxb is a hypothetical mathematical function used in fixed-point arithmetic to truncate a real number to a fixed-point representation specified by two width parameters, x and b. The function is defined for applications where a real input must be represented as a scaled integer with a fixed number of fractional bits, while constraining the overall word width.

Definition and parameters: For integers x ≥ 2 and b ≥ 0, mathtruncxb(r, x, b) produces an integer

Semantics and use: The function truncates toward zero, yielding a fixed-point representation whose error is less

Example: mathtruncxb(3.75, 4, 2) equals 15, representing 3.75 in a Q4.2 fixed-point format (since 15 / 2^2 =

Implementation notes: In practice, the operation is implemented as result = sign(r) × floor(|r| × 2^b) with

that
encodes
the
fixed-point
value
of
r
with
b
fractional
bits.
Formally,
mathtruncxb(r,
x,
b)
=
sign(r)
×
floor(|r|
×
2^b).
The
representable
range
of
results
is
[-2^(x−1)
×
2^b,
(2^(x−1)
−
1)
×
2^b].
If
the
computed
value
lies
outside
this
range,
the
result
is
saturated
(clamped)
to
the
nearest
bound.
This
ensures
the
output
fits
in
a
fixed-point
word
with
x
integer
bits
and
b
fractional
bits.
than
2^(−b)
in
magnitude.
It
is
distinct
from
rounding-to-nearest
or
from
floor
for
negative
inputs,
which
can
produce
different
results.
Mathtruncxb
is
commonly
discussed
in
contexts
such
as
embedded
systems,
digital
signal
processing,
and
simulations
that
rely
on
precise,
predictable
fixed-point
behavior
rather
than
floating-point
dynamics.
3.75).
mathtruncxb(-2.5,
4,
2)
equals
−10,
representing
−2.50
in
the
same
format
(−10
/
4
=
−2.5).
subsequent
saturation
to
the
fixed-point
range
defined
by
x
and
b.