• Api Documentation
Show / Hide Table of Contents
  • System.Numerics
    • BigRational
      • Abs
      • Acos
      • Acosh
      • AcosPi
      • Addition
      • Asin
      • Asinh
      • AsinPi
      • Atan
      • Atan2
      • Atan2Pi
      • Atanh
      • AtanPi
      • BigRational
      • BitwiseOr
      • Cbrt
      • Ceiling
      • Clamp
      • CompareTo
      • CopySign
      • Cos
      • Cosh
      • CosPi
      • CreateChecked
      • CreateSaturating
      • CreateTruncating
      • Decrement
      • Division
      • Equality
      • Equals
      • Exp
      • Exp10
      • Exp10M1
      • Exp2
      • Exp2M1
      • Explicit
      • ExpM1
      • Factorial
      • Floor
      • GetHashCode
      • GreaterThan
      • GreaterThanOrEqual
      • Hypot
      • ILog10
      • ILog2
      • ILogB
      • Implicit
      • Increment
      • Inequality
      • IsInteger
      • IsNaN
      • LessThan
      • LessThanOrEqual
      • Log
      • Log10
      • Log10P1
      • Log2
      • Log2P1
      • LogP1
      • Max
      • MaxDigits
      • MaxMagnitude
      • MaxMagnitudeNumber
      • Min
      • MinMagnitude
      • MinMagnitudeNumber
      • Modulus
      • Multiply
      • NumDen
      • op_CheckedExplicit
      • Parse
      • Pi
      • Pow
      • Pow2
      • ReadFromBytes
      • RootN
      • Round
      • Sign
      • Sin
      • SinCos
      • SinCosPi
      • Sinh
      • SinPi
      • Sqrt
      • Subtraction
      • Tan
      • Tanh
      • TanPi
      • task_cpu
      • Tau
      • ToString
      • Truncate
      • TryFormat
      • TryParse
      • UnaryNegation
      • UnaryPlus
      • WriteToBytes
    • BigRational.CPU
      • abs
      • add
      • and
      • atan
      • bdi
      • cmp
      • cmpa
      • cmpi
      • CPU
      • dec
      • div
      • dup
      • equ
      • exp
      • fac
      • free
      • gcd
      • getd
      • getf
      • getr
      • gets
      • hash
      • idiv
      • imod
      • inc
      • inv
      • ipt
      • isi
      • lim
      • log
      • log2
      • lsb
      • mark
      • mod
      • msb
      • mul
      • neg
      • norm
      • or
      • pi
      • pop
      • popd
      • popi
      • popr
      • pow
      • push
      • rnd
      • shl
      • shr
      • sign
      • sin
      • sqr
      • sqrt
      • sub
      • swp
      • tor
      • tos
      • xor
    • BigRational.Integer
      • Abs
      • Add
      • Addition
      • BitwiseAnd
      • BitwiseOr
      • CompareTo
      • CreateChecked
      • CreateSaturating
      • CreateTruncating
      • Decrement
      • Divide
      • Division
      • DivRem
      • Equality
      • Equals
      • ExclusiveOr
      • Explicit
      • GetByteCount
      • GetHashCode
      • GreaterThan
      • GreaterThanOrEqual
      • GreatestCommonDivisor
      • Implicit
      • Increment
      • Inequality
      • Integer
      • IsEven
      • IsEvenInteger
      • IsNegative
      • IsOddInteger
      • IsOne
      • IsPositive
      • IsPow2
      • IsPowerOfTwo
      • IsZero
      • LeastCommonMultiple
      • LeftShift
      • LessThan
      • LessThanOrEqual
      • Log
      • Log10
      • Log2
      • Lsb
      • Max
      • MaxMagnitude
      • Min
      • MinMagnitude
      • MinusOne
      • ModPow
      • Modulus
      • Msb
      • Multiply
      • Multiply
      • Negate
      • One
      • OnesComplement
      • op_UnsignedRightShift
      • Parse
      • PopCount
      • Pow
      • Remainder
      • RightShift
      • RotateLeft
      • RotateRight
      • Shl
      • Shr
      • Sign
      • Subtract
      • Subtraction
      • ToByteArray
      • ToString
      • TrailingZeroCount
      • TryFormat
      • TryParse
      • TryWriteBytes
      • UnaryNegation
      • UnaryPlus
      • Zero
    • BigRational.SafeCPU
      • abs
      • add
      • and
      • atan
      • bdi
      • cmp
      • cmpa
      • cmpi
      • dec
      • div
      • dup
      • equ
      • exp
      • fac
      • free
      • gcd
      • getd
      • getf
      • getr
      • gets
      • hash
      • idiv
      • imod
      • inc
      • inv
      • ipt
      • isi
      • lim
      • log
      • log2
      • lsb
      • mark
      • mod
      • msb
      • mul
      • neg
      • norm
      • or
      • pi
      • pop
      • popd
      • popi
      • popr
      • pow
      • push
      • rnd
      • shl
      • shr
      • sign
      • sin
      • sqr
      • sqrt
      • sub
      • swp
      • tor
      • tos
      • xor
  • System.Numerics.Generic
    • Float<T>
      • Abs
      • Acos
      • Acosh
      • AcosPi
      • Addition
      • Asin
      • Asinh
      • AsinPi
      • Atan
      • Atan2
      • Atan2Pi
      • Atanh
      • AtanPi
      • BitCount
      • BitDecrement
      • BitIncrement
      • Cbrt
      • Ceiling
      • CompareTo
      • Cos
      • Cosh
      • CosPi
      • CreateChecked
      • CreateSaturating
      • CreateTruncating
      • Decrement
      • Division
      • E
      • Epsilon
      • Equality
      • Equals
      • Exp
      • Exp10
      • Exp2
      • Explicit
      • Float
      • Floor
      • FusedMultiplyAdd
      • GetHashCode
      • GreaterThan
      • GreaterThanOrEqual
      • Hypot
      • Ieee754Remainder
      • ILogB
      • Implicit
      • Increment
      • Inequality
      • IsEvenInteger
      • IsFinite
      • IsInfinity
      • IsInteger
      • IsNaN
      • IsNegative
      • IsNegativeInfinity
      • IsNormal
      • IsOddInteger
      • IsPositive
      • IsPositiveInfinity
      • IsPow2
      • IsRealNumber
      • IsSubnormal
      • LessThan
      • LessThanOrEqual
      • Log
      • Log10
      • Log2
      • Max
      • MaxDigits
      • MaxMagnitude
      • MaxMagnitudeNumber
      • MaxNumber
      • MaxValue
      • Min
      • MinMagnitude
      • MinMagnitudeNumber
      • MinNumber
      • MinValue
      • Modulus
      • Multiply
      • NaN
      • NegativeInfinity
      • NegativeZero
      • Parse
      • Pi
      • PositiveInfinity
      • Pow
      • Pow10
      • RootN
      • Round
      • ScaleB
      • Sign
      • Sin
      • SinCos
      • SinCosPi
      • Sinh
      • SinPi
      • Sqrt
      • Subtraction
      • Tan
      • Tanh
      • TanPi
      • Tau
      • ToString
      • Truncate
      • TryFormat
      • TryParse
      • UnaryNegation
      • UnaryPlus
    • Int<T>
      • Abs
      • Addition
      • BitwiseAnd
      • BitwiseOr
      • Clamp
      • CompareTo
      • CopySign
      • CreateChecked
      • CreateSaturating
      • CreateTruncating
      • Decrement
      • Division
      • DivRem
      • Equality
      • Equals
      • ExclusiveOr
      • Explicit
      • GetHashCode
      • GreaterThan
      • GreaterThanOrEqual
      • Implicit
      • Increment
      • Inequality
      • IsEvenInteger
      • IsNegative
      • IsOddInteger
      • IsPositive
      • IsPow2
      • LeadingZeroCount
      • LeftShift
      • LessThan
      • LessThanOrEqual
      • Log2
      • Max
      • MaxMagnitude
      • MaxValue
      • Min
      • MinMagnitude
      • MinValue
      • Modulus
      • Multiply
      • NegativeOne
      • One
      • OnesComplement
      • op_UnsignedRightShift
      • Parse
      • PopCount
      • RightShift
      • RotateLeft
      • RotateRight
      • Sign
      • Subtraction
      • ToString
      • TrailingZeroCount
      • TryFormat
      • TryParse
      • UnaryNegation
      • UnaryPlus
      • Zero
    • UInt<T>
      • Addition
      • BitwiseAnd
      • BitwiseOr
      • Clamp
      • CompareTo
      • CreateChecked
      • CreateSaturating
      • CreateTruncating
      • Decrement
      • Division
      • DivRem
      • Equality
      • Equals
      • ExclusiveOr
      • Explicit
      • GetHashCode
      • GreaterThan
      • GreaterThanOrEqual
      • Implicit
      • Increment
      • Inequality
      • IsEvenInteger
      • IsOddInteger
      • IsPow2
      • LeadingZeroCount
      • LeftShift
      • LessThan
      • LessThanOrEqual
      • Log2
      • Max
      • MaxValue
      • Min
      • MinValue
      • Modulus
      • Multiply
      • One
      • OnesComplement
      • op_UnsignedRightShift
      • Parse
      • PopCount
      • RightShift
      • RotateLeft
      • RotateRight
      • Sign
      • Subtraction
      • ToString
      • TrailingZeroCount
      • TryFormat
      • TryParse
      • UnaryPlus
      • Zero

Class BigRational.CPU

Represents a virtual stack machine for rational and arbitrary arithmetic.

Inheritance
System.Object
BigRational.CPU
Namespace: System.Numerics
Assembly: System.Numerics.Rational.dll
Syntax
public sealed class CPU : Object
Remarks

Note: In difference to a BigRational.SafeCPU a BigRational.CPU instance can also be used in:
in asynchronous methods, asynchronous lambda expressions, query expressions, iterator blocks and inside non-static nested functions.

Constructors

Name Description
CPU(UInt32)

Initializes a new instance of a BigRational.CPU class that has the specified initial stack capacity.

Methods

Name Description
abs(Int32)

Convert the value at index a relative to the top of the stack to it's absolute value.
Default index 0 addresses the value on top of the stack.

add()

Adds the first two values on top of the stack and replaces them with the result.

add(Int32, Int32)

Adds the values at index a and b relative to the top of the stack and replaces the value at index a with the result.

add(BigRational)

Adds value a and the value on top of the stack.
Replaces the value on top of the stack with the result.

add(BigRational, BigRational)

Adds the values a and b and pushes the result on the stack.

add(UInt32)

Adds the value at index a as absolute index in the stack and the value on top of the stack.
Replaces the value on top of the stack with the result.

add(UInt32, UInt32)

Adds the values at index a and b as absolute indices in the stack and pushes the result on top of the stack.

and()

Bitwise logical AND of the numerators
of the first two values on top of the stack and replaces them with the result.

atan(UInt32)

Replaces the value on top of the stack with the atan of that value.
The value interpreted as an angle is measured in radians.

bdi()

Returns the MSB difference of numerator and denominator for the value at the top of the stack.
msb(numerator) - msb(denominator)
Mainly intended for fast break criterias in iterations as alternative to relatively slow comparisons.
For example, 1e-24 corresponds to a BDI value of -80 since msb(1e+24) == 80

cmp(Int32, Int32)

Compares the values at index a and b relative to the top of the stack.

cmp(BigRational)

Compares the value on top of the stack a with the BigRational value b.

cmp(BigRational, BigRational)

Compares the BigRational value a with the BigRational value b.

cmp(UInt32)

Compares the value on top of the stack with the value at b as absolute index in the stack.

cmp(UInt32, UInt32)

Compares the values at index a and b as absolute indices in the stack.

cmpa(Int32, Int32)

Compares the absolute values at index a and b relative to the top of the stack.

cmpi(Int32, Int32)

Compares the values at index a relative to the top of the stack with the System.Int32 value b.

dec()

Decrements the value on top of the stack.

div()

Divides the first two values on top of the stack and replaces them with the result.

div(Int32, Int32)

Divides the values at index a and b relative to the top of the stack and replaces the value at index a with the result.

div(BigRational, Int32)

Divides the value a and the value at index b relative to the top of the stack.
Pushes the result on top of the stack.

div(BigRational, BigRational)

Divides the values a and b and pushes the result on the stack.

div(UInt32, UInt32)

Divides the values at index a and b as absolute indices in the stack and pushes the result on top of the stack.

dup(Int32)

Duplicates the value at index a relative to the top of the stack and pushes it as copy on top of the stack.

dup(UInt32)

Duplicates the value at index a as absolute index in the stack and pushes it as copy on top of the stack.

equ(BigRational, BigRational)

Compares the BigRational value a with the BigRational value b for equality.

equ(UInt32, BigRational)

Compares the value at index a as absolute index in the stack with the BigRational value b for equality.

equ(UInt32, UInt32)

Compares the values at index a and b as absolute indices in the stack for equality.

exp(UInt32)

Replaces the value on top of the stack with e raised to the power of that value.

fac(UInt32)

Pushes the factorial of the specified number c on the stack.

free()

Frees the current thread static instance of the BigRational.CPU and associated buffers.
A new BigRational.CPU is then automatically created for subsequent calculations.

gcd()

Finds the greatest common divisor (GCD) of the numerators
of the first two values on top of the stack and replaces them with the result.

getd(UInt32)

Converts the value at absolute position i on stack to a System.Double value and returns it.

getf(UInt32)

Converts the value at absolute position i on stack to a System.Single value and returns it.

getr(UInt32)

Converts the value at absolute position i on stack to a always normalized BigRational number and returns it.

gets(UInt32)

Exposes the internal data representation of the value at absolute position i on the stack.

hash(UInt32)

Calculates a hash value for the value at b as absolute index in the stack.

idiv()

Performs an integer division of the numerators of the first two values on top of the stack
and replaces them with the integral result.

imod()

Performs an integer division of the numerators of the first two values on top of the stack
and replaces them with the integral result.

inc()

Increments the value on top of the stack.

inv(Int32)

Replaces the value at index i relative to the top of the stack
with it's multiplicative inverse, also called the reciprocal. x = 1 / x;

ipt()

Evaluates whether the numerator of the value on top of the stack is a power of two.

isi()

Returns whether the value on top of the stack is an integer.

lim(UInt32, Int32)

Limitates the binary digits of the value at the top of the stack to the specified count c.
If the number of digits in numerator or denominator exceeds this count the bits will shifted right by the difference.

log(UInt32)

Replaces the value on top of the stack with it's natural (base e) logarithm. Non-positive values result in NaN.

log2(UInt32)

Replaces the value on top of the stack with it's base 2 logarithm. Non-positive values result in NaN.

lsb()

Returns the LSB (least significant bit) of the numerator of the value on top of the stack.

mark()

Returns a temporary absolute index of the current stack top from which subsequent instructions can index stack entries.

mod(Int32)

Pops the value at the top of the stack.
Divides the numerator by the denominator and pushes the remainder and the quotient as integer values on the stack.

msb()

Returns the MSB (most significant bit) of the numerator of the value on top of the stack.

mul()

Multiplies the first two values on top of the stack and replaces them with the result.

mul(Int32, Int32)

Multiplies the values at index a and b relative to the top of the stack and replaces the value at index a with the result.

mul(BigRational)

Multiplies value a and the value on top of the stack.
Replaces the value on top of the stack with the result.

mul(BigRational, BigRational)

Multiplies the values a and b and pushes the result on the stack.

mul(BigRational, UInt32)

Multiplies the value a and the value at b as absolute index in the stack and pushes the result on the stack.

mul(UInt32)

Multiplies the value at index a as absolute index in the stack and the value on top of the stack.
Replaces the value on top of the stack with the result.

mul(UInt32, UInt32)

Multiplies the values at index a and b as absolute indices in the stack and pushes the result on top of the stack.

neg(Int32)

Negates the value at index a relative to the top of the stack.

neg(UInt32)

Negates the value at index a as absolute index in the stack.

norm(Int32)

Normalize the value at the specified index relative to the top of the stack.

or()

Bitwise logical OR of the numerators
of the first two values on top of the stack and replaces them with the result.

pi(UInt32)

Calculates π (PI) to the desired precision and push it to the stack.
Represents the ratio of the circumference of a circle to its diameter.

pop()

Removes the value currently on top of the stack.

pop(Int32)

Removes n values currently on top of the stack.

popd()

Removes the value currently on top of the stack, convert and returns it as System.Double value.

popi()

Removes the value currently on top of the stack, convert the numerator and returns it as System.Int32 value.

popr()

Removes the value currently on top of the stack, convert and returns it as always normalized BigRational number.

pow(Int32)

Replaces the value on top of the stack with the power of this number to the specified power y.

pow(Int32, Int32)

Pushes the specified number x raised to the specified power y to the stack.

push()

Pushes a 0 (zero) value onto the stack.

push(Decimal)

Pushes the supplied System.Decimal value onto the stack.

push(Double)

Pushes the supplied System.Double value onto the stack.

push(Double, Boolean)

Pushes the supplied System.Double value onto the stack using a bit-exact conversion without rounding.

push(Int32)

Pushes the supplied System.Int32 value onto the stack.

push(Int32, Int32)

Pushes n copies of the supplied System.Int32 value onto the stack.

push(Int64)

Pushes the supplied System.Int64 value onto the stack.

push(BigInteger)

Pushes the supplied System.Numerics.BigInteger value onto the stack.

push(BigRational)

Pushes the supplied BigRational value onto the stack.

push(ReadOnlySpan<UInt32>)

Pushes the supplied value onto the stack.

push(Single)

Pushes the supplied System.Single value onto the stack.

push(UInt32)

Pushes the supplied System.UInt32 value onto the stack.

push(UInt64)

Pushes the supplied System.UInt64 value onto the stack.

rnd(Int32, Int32)

Rounds the value at the top of the stack to the specified number of fractional decimal digits.

shl(Int32, Int32)

Selects the value at index i relative to the top of the stack.
Shifts the numerator value to the left (in zeros) by the specified number of bits.

shr(Int32, Int32)

Selects the value at index i relative to the top of the stack.
Shifts the numerator value to the right (in zeros) by the specified number of bits.

sign(Int32)

Gets a number that indicates the sign of the value at index i relative to the top of the stack.
Default index 0 returns the sign of the value on top of the stack.

sin(UInt32, Boolean)

Replaces the value on top of the stack with the sine or cosine of that value.
The value interpreted as an angle is measured in radians.

sqr(Int32)

Squares the value at index a relative to the top of the stack.
Default index 0 squares the value on top of the stack.

sqr(UInt32)

Squares the value at index a as absolute index in the stack.

sqrt(UInt32)

Replaces the value on top of the stack with it's square root. Negative values result in NaN.

sub()

Subtract the first two values on top of the stack and replaces them with the result.

sub(Int32, Int32)

Subtracts the values at index a and b relative to the top of the stack and replaces the value at index a with the result.

sub(BigRational, BigRational)

Subtracts the values a and b and pushes the result on the stack.

sub(UInt32, UInt32)

Subtracts the values at index a and b as absolute indices in the stack and pushes the result on top of the stack.

swp()

Swaps the first two values on top of the stack.

swp(Int32, Int32)

Swaps the values at index a and b relative to the top of the stack.

swp(UInt32)

Swaps the values at index a as absolute index with the value on top of the stack.

swp(UInt32, UInt32)

Swaps the values at index a and b as absolute indices in the stack.

tor(ReadOnlySpan<Char>, Int32, Char)

Converts a string to a rational number and pushes the result on the stack.

tos(Span<Char>, out Int32, out Int32, out Int32, Boolean)

Converts the value on top of the stack to decimal digits.

xor()

Bitwise logical XOR of the numerators
of the first two values on top of the stack and replaces them with the result.

In This Article
Back to top Generated by DocFX