Integer related functions#
Integral value nearest \(x\) (rounding to nearest): \(\mathrm{nearbyint}(x), \mathrm{rint}(x)\)#
- ctx.rint(x)#
where
ctxismath53,ctxboostorctxflint.Returns the integral value (in floating-point format) nearest \(x\), using the
rounding-to-nearestrounding mode.For the std::rint function:
If num is ±∞, it is returned, unmodified.
If num is ±0, it is returned, unmodified.
If num is NaN, NaN is returned.
See also: https://en.cppreference.com/w/cpp/numeric/math/nearbyint
See also: https://en.cppreference.com/w/cpp/numeric/math/rint
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Rint(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Rint('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Rint(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Rint('0.51') Gpr('5.3518479027559984754E-1')
- ctx.nearbyint(x)#
Is an alias for
ctx.rint(x)in this implementation. The only difference betweenstd::rintandstd::nearbyintis thatstd::nearbyintnever raisesFE_INEXACT.
32 bit integer nearest \(x\) (rounding to nearest): \(\mathrm{lrint}(x)\)#
- ctx.lrint(x)#
where
ctxismath53,ctxboostorctxflint.Returns an 32 bit signed integer nearest \(x\), using the
rounding-to-nearestrounding mode.If the result is outside the range representable by an 32 bit signed integer, a domain error or a range error may occur.
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Rint(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Rint('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Rint(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Rint('0.51') Gpr('5.3518479027559984754E-1')
64 bit integer nearest \(x\) (rounding to nearest): \(\mathrm{llrint}(x)\)#
- ctx.llrint(x)#
where
ctxismath53,ctxboostorctxflint.Returns an 64 bit signed integer nearest \(x\), using the
rounding-to-nearestrounding mode.If the result is outside the range representable by an 64 bit signed integer, a domain error or a range error may occur.
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Rint(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Rint('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Rint(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Rint('0.51') Gpr('5.3518479027559984754E-1')
Smallest integral value not less than \(x: \mathrm{ceil}(x)\)#
- ctx.ceil(x)#
where
ctxismath53,ctxboostorctxflint.Returns the smallest integer \(> x; |x| \le\) MaxLongint.
See also: https://en.cppreference.com/w/cpp/numeric/math/ceil
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Ceil(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Ceil('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Ceil(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Ceil('0.51') Gpr('5.3518479027559984754E-1')
Largest integral value not greater than \(x: \mathrm{floor}(x)\)#
- ctx.floor(x)#
where
ctxismath53,ctxboostorctxflint.Returns the largest integer \(< x; |x| \le\) MaxLongint.
See also: https://en.cppreference.com/w/cpp/numeric/math/floor
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Floor(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Floor('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Floor(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Floor('0.51') Gpr('5.3518479027559984754E-1')
Nearest integral value not greater in magnitude than \(x: \mathrm{trunc}(x)\)#
- ctx.trunc(x)#
where
ctxismath53,ctxboostorctxflint.Returns the truncated value of \(x\).
See also: https://en.cppreference.com/w/cpp/numeric/math/trunc
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Truncate(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Truncate('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Truncate(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Truncate('0.51') Gpr('5.3518479027559984754E-1')
Nearest integral value, rounding halfway cases away from zero: \(\mathrm{round}(x)\)#
- ctx.round(x)#
where
ctxismath53,ctxboostorctxflint.Computes the nearest integer (in floating-point format), rounding halfway cases away from zero, regardless of the current rounding mode.
See also: https://en.cppreference.com/w/cpp/numeric/math/round
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Round(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Round('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Round(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Round('0.51') Gpr('5.3518479027559984754E-1')
Nearest 32 bit integer, rounding halfway cases away from zero: \(\mathrm{lround}(x)\)#
- ctx.lround(x)#
where
ctxismath53,ctxboostorctxflint.Returns the nearest 32 bit signed integer, rounding halfway cases away from zero.
See also: https://en.cppreference.com/w/cpp/numeric/math/round
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Round(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Round('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Round(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Round('0.51') Gpr('5.3518479027559984754E-1')
Nearest 64 bit integer, rounding halfway cases away from zero: \(\mathrm{llround}(x)\)#
- ctx.llround(x)#
where
ctxismath53,ctxboostorctxflint.Returns the nearest 64 bit signed integer, rounding halfway cases away from zero.
See also: https://en.cppreference.com/w/cpp/numeric/math/round
An example in Python
>>> from xlcalcnet import xreal >>> xreal.Round(0.5) xreal('5.2359877559829887307E-1') >>> xreal.Round('0.51') xreal('5.3518479027559984754E-1')
An example in Visual Basic
>>> from xlcalcnet import Gpr >>> Gpr.Round(0.5) Gpr('5.2359877559829887307E-1') >>> Gpr.Round('0.51') Gpr('5.3518479027559984754E-1')