Skip to main content
Ctrl+K

XlCalcNet Documentation

  • Preface

Getting started

  • Setup and general usage
    • Setting up XlCalcNet
    • General and user interface functions
    • Calling Python from C#
    • Using XlCalcNet with spreadsheet formulas
    • Mathematical functions based on Mpmath, Gmpy2 and Python-Flint (only Python)
    • Mathematical functions in fixed precision
    • Mathematical functions based on XlCalcNet2
    • A quick look at Numpy
    • A quick look at Matplotlib and related libraries
    • A quick look at Pandas and Xlxswriter
    • A quick look at Scipy
    • A quick look at R, RStudio and Rpy2
  • Basic floating point functions
    • Operator overloading, general real functions
    • Machine constants, general
    • Properties of numbers
    • Integer related functions
    • Floating point functions for real numbers
    • Fraction and remainder related functions
    • Functions related to mantissa width and exponent range
    • Mathematical Constants
  • Elementary scalar functions (real and complex)
    • Complex components
    • Roots and quadratic, cubic, and quartic equations
    • Exponential and related functions
    • Logarithms and related functions
    • Power functions
    • Trigonometric functions, in radians
    • Trigonometric functions, in multiples of \(\pi\)
    • Hyperbolic functions
    • Inverse trigonometric functions, in radians
    • Inverse hyperbolic functions
    • Factorials, Gamma and related functions
    • Miscellaneous functions
  • Statistical Distributions
    • Introduction to random variables and distributions
    • Base class for univariate distributions
    • Base class for continuous univariate distributions
    • Base class for discrete univariate distributions
    • Closed form distributions, based on elementary functions
      • Boost: Arcsine Distribution
      • Boost: Cauchy distribution
      • Boost: Exponential distribution
      • Boost: Gumbel (Generalized Extreme Value distribution Type-I) distribution
      • Boost: Hyperexponential Distribution
      • !!!Boost: Kumaraswamy distribution
      • Boost: Laplace distribution
      • Boost: Logistic distribution
      • Boost: Pareto distribution
      • Boost: Rayleigh distribution
      • Boost: Triangular Distribution
      • Boost: Uniform distribution
      • Boost: Weibull (Minimum-Type-III) distribution
      • Dagum (Burr Type III) distribution
      • Fisk (log-logistic) distribution
      • Fréchet (Maximum/Minimum-Type-II or Inverse Weibull) distribution
      • Generalized Extreme Value (Maximum) or GEV distribution
      • Generalized Pareto distribution
      • Gompertz-Makeham distribution
      • Lomax distribution
      • Shifted Gompertz distribution
      • Singh-Maddala (Burr Type XII) distribution
    • Closed form distributions, based on the error function
      • !!!Boost: Lévy distribution
      • Boost: Lognormal (Johnson \(S_L\)) distribution
      • !!!Boost: Moyal Distribution
      • Boost: Normal (Johnson \(S_N\)) distribution
      • Boost: Skew normal Distribution
      • Boost: Wald (or Inverse Gaussian) distribution
      • Birnbaum-Saunders Distribution
      • Exponentially Modified Gaussian (EMG) distribution
      • Folded normal distribution
      • Half-normal distribution
      • Johnson \(S_B\) distribution
      • Johnson \(S_U\) distribution
      • Normal maximum distribution, \(\rho_{ij, i \ne j} = 0\)
      • Normal maximum modulus distribution, \(\rho_{ij, i \ne j} = 0\)
      • Sinh-arcsinh normal distribution
      • Truncated normal distribution
    • Closed form distributions, based on the incomplete gamma function
      • !!!Boost: Chi Distribution
      • Boost: Chi-Squared distribution
      • Boost: Gamma (Pearson Type III, Erlang) distribution
      • Boost: Inverse chisquared distribution
      • Boost: Inverse Gamma (Pearson Type V) distribution
      • !!!Boost: Maxwell Distribution
      • !!!Boost: Nakagami distribution
      • Amoroso distribution
      • Distribution of the logarithm of a \(\chi^2\) random variable
      • Hypoexponential (Generalized Erlang) Distribution
      • Lindley distribution (generalized)
      • Skew exponential power distribution
      • Stacy (generalized gamma) distribution
    • Closed form distributions, based on the incomplete beta function
      • Boost: Beta (Pearson Type I and II) distribution
      • Boost: Central Fisher F distribution
      • Boost: Student \(t\) (Pearson Type VII) distribution
      • Distribution of the negative logarithm of a beta variable
      • Beta-prime (Pearson Type VI) distribution
      • Generalized Beta (Type 1) distribution
      • Generalized Beta (Type 2) distribution
      • Generalized logistic distribution (JKB Types I - IV)
      • Generalized beta-exponential distribution
      • Feller-Pareto distribution
      • Fisher \(z\) distribution
      • Skew t-distribution (Jones)
      • Pearson’s rho distribution (under \(H_0\))
    • Noncentral distributions
      • Boost: Noncentral \(\chi^2\) distribution
      • Boost: Noncentral Student \(t\) distribution
      • Boost: Noncentral Fisher \(F\) distribution
      • Boost: Noncentral Beta Type I distribution
      • Noncentral Chi distribution
      • Rice (Nakagami-n) distribution
      • Noncentral distribution of the sample correlation coefficient
      • Distribution of the logarithm of a noncentral Beta Type II variable
      • Noncentral distribution (Type I) of Fisher’s \(R^2\)
      • Distribution of the logarithm of a noncentral Fisher \(1-R^2\) variable
      • Doubly non-central Student \(t\) distribution
      • Doubly non-central Fisher \(F\) distribution
    • Distributions related to multiple comparisons of means
      • Overview and literature
      • Normal maximum distribution, \(\rho_{ij, i \ne j} = \rho\)
      • Normal maximum modulus distribution, \(\rho_{ij, i \ne j} = \rho\)
      • Normal maximum distribution, \(\rho_{ij, i \ne j} = \lambda_i \lambda_j\)
      • Normal maximum modulus distribution, \(\rho_{ij, i \ne j} = \lambda_i \lambda_j\)
      • Normal range distribution
      • Studentized maximum distribution
      • Studentized maximum modulus distribution
      • Distribution of Dunnett’s \(t\), one-sided
      • Distribution of Dunnett’s \(t\), two-sided
      • Nair’s \(t\)-distribution
      • Halperin’s \(t\)-distribution
      • Nelson’s \(h\)-distribution
      • Studentized range distribution
    • Distributions related to multivariate statistical analysis
      • Distribution of the sum of the negative logarithms of independent beta variables
      • Distribution of the product of independent beta variables
      • Distribution of Wilks’ \(\Lambda\)
      • Distribution of Wilks’ \(L_{vc}\)
      • Distribution of Wilks’ \(L_{vcm}\)
      • Distribution of Wilks’ test of independence of \(p\) variates
      • Distribution of Wilks’ test of independence of \(k\) groups of variates
      • Distribution of Mauchly’s test of sphericity vs general structure
      • Distribution of Box’s test of equality of covariance matrices, equal sample sizes
      • Distribution of Box’s test of equality of k covariance matrices, unequal sample sizes
      • Distribution of Box’s test for same multivariate normal distributions, unequal sample sizes
      • Distribution of the modified likelihood ratio test (LRT) for a given covariance matrix
      • Distribution of the modified likelihood ratio test (LRT) for a given covariance matrix and mean vector
      • Central distribution of Roy’s largest root
      • Central distribution of Pillai’s \(V\)
      • Central distribution of Hotelling’s \(T^2\)
      • Noncentral Distribution of Wilks’ \(\Lambda\): MANOVA
      • Noncentral Distribution of Wilks’ \(\Lambda\): Canonical Correlation
    • Miscellaneous continuous distributions
      • Boost: Kolmogorov-Smirnov distribution (limiting form)
      • Boost: Landau Distribution
      • Boost: Holtsmark distribution
      • Boost: Map-Airy distribution
      • Boost: Saspoint5 distribution
      • Lévy alpha-stable distribution
      • Pearson Type IV distribution
      • Meixner distribution
      • Voigt Profile Distribution
      • Wrapped Cauchy distribution
      • Wrapped normal distribution
      • Von Mises distribution
      • Generalized inverse Gaussian distribution
      • Harmonic distribution
      • Halphen A distribution
      • Halphen B distribution
      • Halphen IB distribution
      • Generalized hyperbolic distribution
      • Hyperbolic distribution
      • Variance-gamma distribution
    • Elementary discrete (lattice) distributions
      • Boost: Bernoulli distribution
      • Boost: Geometric distribution
      • Boost: Poisson distribution
      • Boost: Binomial distribution
      • Boost: Negative binomial distribution
      • Boost: Classical hypergeometric distribution
      • Log-series distribution
      • Zeta distribution
      • Skellam distribution
      • Delaporte distribution
      • Beta-Poisson distribution (Quinkert)
      • Beta-binomial distribution
      • Beta-negative binomial distribution (Waring)
      • Negative hypergeometric distribution
      • Pólya-Eggenberger distribution
      • General hypergeometric distribution
      • Noncentral hypergeometric distribution, Fisher alternatives
    • Discrete (lattice) distributions related to (stratified) rank tests
      • Wilcoxon signed rank T distribution, continuous data
      • Noncentral Wilcoxon signed rank T distribution, Bennett alternatives
      • Mann-Whitney U distribution, continuous data
      • Noncentral Mann-Whitney U distribution, Lehmann alternatives
      • Noncentral Mann-Whitney U distribution, Milton alternatives
      • Kendall’s tau distribution, continuous data
      • Jonckheere-Terpsta \(T\) distribution, continuous data
      • Generalized Page \(L\) distribution, continuous data
      • Noncentral generalized Page \(L\) distribution, Milton alternatives
    • Discrete (non-lattice) distributions related to rank tests
      • Cochran-Friedman-Quade distribution
      • Kruskal-Wallis distribution
  • Numerical calculus
    • Introduction
    • DAMath: Numerical Rootfinding and Minimization
    • Boost/Math: Root Finding and Minimization Algorithms
    • Mpmath: Rootfinding and optimization
    • DAMath: Numerical Quadrature
    • Boost/Math: Numerical integration
    • Mpmath: Numerical integration
    • Mpmath: Numerical inverse Laplace transform
    • Boost/Odeint: Ordinary differential equations
    • Mpmath: Numerical differentiation
    • Mpmath: Asymptotic expansions
    • Mpmath: Function approximation
    • Mpmath: Sums, products, limits and extrapolation
    • Mpmath: Number identification
    • Mpmath: Polynomials
    • Eigen: Polynomials
    • Eigen/MinPack: non linear optimization
    • Eigen/CppOptLib: multidimensional optimization
    • Flint/Functions for polynomials
    • Flint/Power series and Taylor arithmetic
    • Flint/Verified numerical differentiation
    • Flint/Verified numerical integration
  • Eigen: Dense and Sparse Matrices
    • Creating scalars and matrices
    • Read-only properties: information about a matrix
    • Accessing and setting parts of a matrix
    • Changing the shape of a matrix and/or the order of coefficients
    • Basic arithmetic operations
    • Descriptive Statistics
    • Standard decompositions and linear solving
    • Singular Value and Eigen (selfadjoint) decompositions
    • Eigen decompositions of general square matrices
    • Eigen: Functions of matrix argument
    • Eigen: Fast Fourier Transform
  • Numpy: use with multiprecision data types
    • Numpy array creation from shape or value
    • Numpy array creation from existing data
    • Building special arrays for numerical work
    • Numpy indexing
    • Numpy basic array manipulation routines
    • Numpy array manipulation: Transpose-like operations
    • Numpy array manipulation: Changing number of dimensions
    • Numpy array manipulation: Joining arrays
    • Numpy array manipulation: Splitting and tiling arrays
    • Numpy array manipulation: Adding and removing elements
    • Numpy array manipulation: Rearranging elements
    • Numpy array manipulation: Sorting
    • Numpy array manipulation: Searching
    • Numpy mathematical functions: Sums, products, differences
    • Numpy mathematical functions: Extrema Finding
    • Numpy mathematical functions: Arithmetic operations, elementwise
    • Numpy mathematical functions: Averages and variances
    • Numpy mathematical functions: Matrix and vector products
    • Numpy logical functions: Truth value testing
    • Numpy mathematical functions: Integer and fractional
    • Numpy mathematical functions: Miscellaneous
    • Summary and examples: Numpy utility functions
    • Arithmetic operations with scalars and iterables
    • Numerical transformations and descriptive statistics
    • Standard decompositions and linear solving
    • Singular Value and Eigen decompositions
    • Analytic functions of a matrix
    • Discrete Fourier transform (DFT)
    • Flint/Functions for matrices

Special Functions

  • Elliptic functions and related
    • Carlson symmetric elliptic integrals
    • Legendre elliptic integrals (elliptic parameter \(m\))
    • Legendre elliptic integrals (elliptic modulus \(k\)), and related functions
    • Jacobi elliptic functions
    • Jacobi theta functions and related functions
    • Conversions of parameters of Weierstrass \(\wp\)
    • Weierstrass elliptic functions, in terms of elliptic period ratio \(\tau\)
    • Modular forms, in terms of half-period \(\omega_1\) and elliptic period ratio \(\tau\)
  • Lerch’s phi and related
    • Lerch’s transcendent and Lerch’s zeta
    • Polygamma and related functions
    • Polylogarithm and related functions
    • Hurwitz zeta and related functions
    • Riemann zeta function, and related functions
  • Hypergeometric function \(\,_0F_1\) and related
    • Hypergeometric Limit Function \(\,_0F_1\)
    • Bessel functions
    • Modified Bessel functions
    • Spherical Bessel functions
    • Modified spherical Bessel functions
    • Hankel functions
    • Airy functions
    • Kelvin functions
  • Hypergeometric function \(\,_1F_1\) and related
    • Hypergeometric Functions \(\,_1F_1\) (Kummer) and \(U\) (Tricomi)
    • Incomplete gamma functions
    • Coulomb, Whittaker and parabolic cylinder function
    • Error function and related functions
    • Exponential integrals, and related functions
  • Hypergeometric functions \(\,_2F_1\) and \(\,_1F_2\) (and related functions)
    • Gauss Hypergeometric Function \(\,_2F_1\)
    • Chebyshev, Gegenbauer and Jacobi polynomials
    • Legendre polynomials and related
    • Incomplete beta functions
    • Hypergeometric function \({}_1F_2\)
    • Scorer functions
    • Struve functions
    • Anger, Weber and Lommel functions

Supporting Functions

  • Algebra with random variables
    • Probability density function (pdf)
    • Probability mass function (pmf)
    • Cumulative distribution function (cdf)
    • Quantile function
    • Characteristic function
    • Moment generating function
    • Cumulant generating function
    • Probability generating function
    • Factorial Moments
    • Raw Moments
    • Central Moments
    • Cumulants
  • Series and integrals
    • Finite series algorithms for selected distributions
    • Infinite series algorithms for selected functions and distributions
    • Finite series for lattice distributions, based on factorial moments
    • Efficient integration of bell-shaped functions
    • Verified numerical integration
  • Pmf vectors
    • Basic discrete (lattice) distribution functions
    • Discrete (lattice) distribution functions related to (stratified) rank tests
    • Discrete (non-lattice) distribution functions related to rank tests
  • Fast approximations
    • Approximations based on the normal distribution
    • Approximations based on the chi-squared distribution
    • Approximations based on the central \(t\), \(F\) or beta distribution
    • Approximations based on the noncentral chi-squared distribution
    • Approximations based on the noncentral F or beta distribution
    • Approximations based on hypergeometric functions of scalar argument

Gallery of Plots

  • Visualisation of datasets
    • Bar Charts
    • Line and lollipop charts
    • Area Plots
    • Boxplot, Violinplot and Raincloud plot
    • Correlation and regression
    • Financial plots (requires mplfinance)
    • Geographic data (requires cartopy)
    • Geographic data (requires geopandas)
    • Parts of a whole
    • Arcplots, dendrograms, heatmaps and clustermaps
    • PlotTable
    • Flow and connections
    • Circular plots and flows
    • Network data (requires networkx)
  • Visualisation of functions and curves (2D)
    • Introduction to 2D functions and curves
    • Basic curves
    • Spirals
    • Decorative curves
    • General curve families
    • Field lines
    • Contours
    • Complex functions rendered as contours
    • Streams, barbs and quivers (some require cartopy)
  • Bitmaps
    • Fractals: introduction
    • Fractals related to the Mandelbrot set
    • Fractals related to the Julia set
    • Newton Fractals
    • Domain coloring options
    • Domain coloring: Examples part 1
  • Matplotlib 3D Graphics
    • Introduction
    • Matplotlib: 3D Graphics, part 2
    • S3dlib: Basic geometric figures
    • S3dlib: Real functions
    • S3dlib: Parametric Surfaces
    • S3dlib: Image mapping and clipping
    • S3dlib: Edge-to-edge surface coloring
    • S3dlib: Decorative parametric surfaces
    • S3dlib: Geometric and color datagrid mapping (requires scipy)
    • S3dlib: Implicit surfaces (requires scikit-image)
  • Plotly
    • General surface plots in 3D
    • Geographical plots
    • Sankey plots

Interactive 3D Wpf Plots

  • Wpf: Altitude surfaces in 3D, real and complex functions
    • Special techniques for height surfaces, real and complex functions
    • Scatterplots and building 3D scenes
    • Height plots of general bivariate real functions
  • Wpf: Parametric surfaces
    • Surfaces of translation
    • Surfaces of revolution: spheres and related
    • Generalisations of common surfaces
    • Minimal surfaces
    • Nonorientable (one-sided) Surfaces
    • Decorative parametric surfaces
  • Wpf: Path surfaces in 3D
    • Introduction to path surfaces
    • Functions with real input and complex results
    • Characteristic functions of statistical distributions
    • Helices and related curves traced on cylinders, cones and spheres
    • Coil springs
    • General knots
    • Torus knots
    • Lissajous knots
    • Polynomial knots
  • Wpf: Built-in 3D objects
    • Builtin solids with support for textures
    • Builtin solids without support for textures
    • Platonic solids, and related solids

User library: numerical

  • Additional Classes
    • User defined functions based on multiple precision arithmetic (Python)
    • User defined functions based on fixed precision arithmetic (C#)
    • User defined functions based on arbitrary precision arithmetic (C#)
    • Scalar functions
  • Distribution functions
    • Distributions related to multiple comparisons of means
    • Discrete (lattice) distribution functions related to (stratified) rank tests
    • Discrete (non-lattice) distribution functions related to rank tests
  • Inferential statistics
    • Basic classical statistical tests (stratified)
    • Basic classical statistical tests for 2 independent samples (stratified)
    • Basic classical statistical tests for 2 correlated samples (stratified)
    • Analysis of variance (ANOVA), orthogonal polynomials, and analysis of means (AOM)
    • Multiple comparisons of means
    • Nonparametric statistical tests, 1 or 2 samples
    • Nonparametric statistical tests, k samples
    • Multivariate statistical tests
  • Addditional elementary functions (real arguments, double precision)
    • Additional root, exponential, logarithmic and power functions
    • Additional Trigonometric functions (real arguments only)
    • Additional real error functions (real arguments only)
    • Additional real gamma functions (real arguments only)
    • Additional real incomplete gamma functions (real arguments only)
  • Addditional special functions (real arguments, double precision)
    • Conversions of parameters of elliptic functions
    • Additional elliptic integrals
    • Bulirsch elliptic integrals
    • Maple style elliptic integrals
    • Jacobi theta functions at \(x=0\) for \(0 \le q <1\)
    • Inverse Jacobi elliptic functions
    • Lemniscate functions
    • Neville theta functions
    • Polygamma, and related functions
    • Polylogarithm, and related functions
    • Riemann zeta, and related functions
    • Bessel functions of integer order
    • Modified Bessel functions of integer order
    • Integrals of zero-order Bessel functions
    • Kelvin functions of order 0
    • Synchrotron functions
    • Error function, and related functions
    • Exponential integrals, and related functions
    • Coulomb, Whittaker and parabolic cylinder function
    • Hypergeometric pFq, and related functions
    • Miscellaneous functions
  • Addditional special functions (complex arguments, double precision)
    • Conversions of parameters of Weierstrass \(\wp\)
    • Weierstrass elliptic functions, in terms of (real) lattice invariants \(g_2, g_3\)
    • Weierstrass elliptic functions, in terms of (real) lattice roots \(e_1, e_2\)
    • Weierstrass elliptic functions, in terms of lattice half-periods \(\omega_1\) and \(\omega_2\)
  • Addditional special functions (Mpmath)
    • Mpmath: Conversions of parameters of elliptic functions
    • Related to Lerch’s phi
    • Additional numbertheoretic functions
    • Generalized hypergeometric functions
    • Appell Functions
    • Q Functions
    • Further generalizations of gamma and hypergeometric functions

Back matter

  • License and History
    • Mozilla Public License Version 2.0
    • History

Indices

  • General Index
  • .rst

Integer related functions

Contents

  • Integral value nearest \(x\) (rounding to nearest): \(\mathrm{nearbyint}(x), \mathrm{rint}(x)\)
    • ctx.rint()
    • ctx.nearbyint()
  • 32 bit integer nearest \(x\) (rounding to nearest): \(\mathrm{lrint}(x)\)
    • ctx.lrint()
  • 64 bit integer nearest \(x\) (rounding to nearest): \(\mathrm{llrint}(x)\)
    • ctx.llrint()
  • Smallest integral value not less than \(x: \mathrm{ceil}(x)\)
    • ctx.ceil()
  • Largest integral value not greater than \(x: \mathrm{floor}(x)\)
    • ctx.floor()
  • Nearest integral value not greater in magnitude than \(x: \mathrm{trunc}(x)\)
    • ctx.trunc()
  • Nearest integral value, rounding halfway cases away from zero: \(\mathrm{round}(x)\)
    • ctx.round()
  • Nearest 32 bit integer, rounding halfway cases away from zero: \(\mathrm{lround}(x)\)
    • ctx.lround()
  • Nearest 64 bit integer, rounding halfway cases away from zero: \(\mathrm{llround}(x)\)
    • ctx.llround()

Integer related functions#

Integral value nearest \(x\) (rounding to nearest): \(\mathrm{nearbyint}(x), \mathrm{rint}(x)\)#

ctx.rint(x)#

where ctx is math53, ctxboost or ctxflint.

Returns the integral value (in floating-point format) nearest \(x\), using the rounding-to-nearest rounding 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 between std::rint and std::nearbyint is that std::nearbyint never raises FE_INEXACT.

32 bit integer nearest \(x\) (rounding to nearest): \(\mathrm{lrint}(x)\)#

ctx.lrint(x)#

where ctx is math53, ctxboost or ctxflint.

Returns an 32 bit signed integer nearest \(x\), using the rounding-to-nearest rounding 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 ctx is math53, ctxboost or ctxflint.

Returns an 64 bit signed integer nearest \(x\), using the rounding-to-nearest rounding 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 ctx is math53, ctxboost or ctxflint.

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 ctx is math53, ctxboost or ctxflint.

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 ctx is math53, ctxboost or ctxflint.

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 ctx is math53, ctxboost or ctxflint.

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 ctx is math53, ctxboost or ctxflint.

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 ctx is math53, ctxboost or ctxflint.

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')

previous

Properties of numbers

next

Floating point functions for real numbers

Contents
  • Integral value nearest \(x\) (rounding to nearest): \(\mathrm{nearbyint}(x), \mathrm{rint}(x)\)
    • ctx.rint()
    • ctx.nearbyint()
  • 32 bit integer nearest \(x\) (rounding to nearest): \(\mathrm{lrint}(x)\)
    • ctx.lrint()
  • 64 bit integer nearest \(x\) (rounding to nearest): \(\mathrm{llrint}(x)\)
    • ctx.llrint()
  • Smallest integral value not less than \(x: \mathrm{ceil}(x)\)
    • ctx.ceil()
  • Largest integral value not greater than \(x: \mathrm{floor}(x)\)
    • ctx.floor()
  • Nearest integral value not greater in magnitude than \(x: \mathrm{trunc}(x)\)
    • ctx.trunc()
  • Nearest integral value, rounding halfway cases away from zero: \(\mathrm{round}(x)\)
    • ctx.round()
  • Nearest 32 bit integer, rounding halfway cases away from zero: \(\mathrm{lround}(x)\)
    • ctx.lround()
  • Nearest 64 bit integer, rounding halfway cases away from zero: \(\mathrm{llround}(x)\)
    • ctx.llround()

By Dietrich Hadler

© Copyright 2026, Dietrich Hadler. .

Last updated on Aug 19, 2026.