v2026.6.4
All Bundles
Bundle Core runtime library providing primitive types (Bool, Byte, Char, Int, Float, String), base collections, and system utilities. Every Objeck program links against this bundle automatically via lang.obl.

Float

Float class represents a double-precision floating-point value

Inherits: Number

Example

pi  := Float->Pi();            # 3.14159...
e   := Float->E();             # 2.71828...
sq  := Float->Sqrt(2.0);       # 1.41421...
rnd := Float->Random();        # 0.0–1.0

Operations

Abs # function

Returns the absolute value

function : Abs() ~ Float

Return

TypeDescription
Floatabsolute value

Example

Float->Abs(-3.14)->PrintLine();  # 3.14

ArcCos # function

Calculates the cosine value

function : ArcCos() ~ Float

Return

TypeDescription
Floatcosine value

ArcCosh # function

Calculates the arc-hyperbolic cosine

function : ArcCosh() ~ Float

Return

TypeDescription
Floathyperbolic arc-cosine value

ArcSin # function

Calculates the arc-sine value

function : ArcSin() ~ Float

Return

TypeDescription
Floatarc-sine value

ArcSinh # function

Calculates the arc-hyperbolic sine

function : ArcSinh() ~ Float

Return

TypeDescription
Floathyperbolic arc-sine value

ArcTan # function

Calculates the arc-tangent value

function : ArcTan() ~ Float

Return

TypeDescription
Floatarc-tangent value

ArcTan2 # function

Calculates arc tangent of y/x

function : ArcTan2(y:Float, x:Float) ~ Float

Parameters

NameTypeDescription
yFloatvalue
xFloatvalue

Return

TypeDescription
Floatarc-tangent value

ArcTanh # function

Calculates the arc-hyperbolic tangent

function : ArcTanh() ~ Float

Return

TypeDescription
Floathyperbolic arc-tangent value

Cbrt # function

Calculates the cubic root

function : Cbrt() ~ Float

Return

TypeDescription
Floatcubic root

Ceil # function

Calculates the ceiling value

function : Ceil() ~ Float

Return

TypeDescription
Floatceiling value

Example

Float->Ceil(3.1)->PrintLine();  # 4.0

Clamp # function

Returns a given value between an upper and lower bound

function : Clamp(min:Float, value:Float, max:Float) ~ Float

Parameters

NameTypeDescription
minFloatminimal value
valueFloatvalue between the min and max
maxFloatmaximum value

Return

TypeDescription
Floatmin if vaule is less than main, max if max is less than value, otherwise the value

Clear # function

Set all array elements to zero

function : Clear(f:Float[]) ~ Nil

Parameters

NameTypeDescription
fFloatarray

Compare # function

Compares two value

function : Compare(l:Float, r:Float) ~ Int

Parameters

NameTypeDescription
lFloatleft compare object
rFloatright compare object

Return

TypeDescription
Int0 if equal, -1 if types differ, 1 if equal

Cos # function

Calculates the cosine value

function : Cos() ~ Float

Return

TypeDescription
Floatcosine value

Example

angle := Float->Pi() / 3.0;
Float->Cos(angle)->PrintLine();  # 0.5

Cosh # function

Calculates the hyperbolic cosine

function : Cosh() ~ Float

Return

TypeDescription
Floathyperbolic cosine value

DoubleFactorial # native

Calculates the double factorial of the value

function : native : DoubleFactorial(n:Float) ~ Float

Parameters

NameTypeDescription
nFloatnumber

Return

TypeDescription
Floatdouble factorial of the value

E # function

Value of E

function : E() ~ Float

Return

TypeDescription
Floatvalue of E

Example

Float->E()->PrintLine();  # 2.718281828...

Error # function

Prints error value

function : Error() ~ Nil

ErrorLine # function

Prints error value with newline

function : ErrorLine() ~ Nil

Exp # function

Calculates exponential value

function : Exp() ~ Float

Return

TypeDescription
Floatexponential value

Factorial # function

Calculates the factorial value

function : Factorial(n:Float) ~ Float

Parameters

NameTypeDescription
nFloatnumber

Return

TypeDescription
Floatfactorial value

Floor # function

Calculates the floor value

function : Floor() ~ Float

Return

TypeDescription
Floatfloor value

Example

Float->Floor(3.9)->PrintLine();  # 3.0

Gamma # function

Calculates the gamma value

function : Gamma() ~ Float

Parameters

NameTypeDescription

Return

TypeDescription
Floatgamma value

Inf # function

Returns a positive infinity value

function : Inf() ~ Float

Return

TypeDescription
Floatpositive infinity value

IsNeg # function

Checks is a number is negative

function : IsNeg() ~ Bool

Return

TypeDescription
Booltrue if negative, false otherwise

Log # function

Calculates the log value

function : Log() ~ Float

Return

TypeDescription
Floatlog value

Example

Float->Log(Float->E())->PrintLine();  # 1.0

Log10 # function

Calculates the common (base-10) logarithm value

function : Log10() ~ Float

Return

TypeDescription
Floatcommon (base-10) logarithm value

Example

Float->Log10(1000.0)->PrintLine();  # 3.0

Log2 # function

Calculates the binary logarithm

function : Log2() ~ Float

Return

TypeDescription
Floatbinary logarithm

Max # native

Returns the largest float value

function : native : Max(l:Float, r:Float) ~ Float

Parameters

NameTypeDescription
lFloatvalue to compare
rFloatvalue to compare

Return

TypeDescription
Floatlargest float value

Min # native

Returns the smallest float value

function : native : Min(r:Float) ~ Float

Parameters

NameTypeDescription
rFloatvalue to compare

Return

TypeDescription
Floatsmallest float value

Mod # function

Calculates the decimal mod

function : Mod(a:Float, b:Float) ~ Float

Parameters

NameTypeDescription
aFloatvalue
bFloatvalue

Return

TypeDescription
Floatdecimial mod

NaN # function

Returns a NaN value

function : NaN() ~ Float

Return

TypeDescription
FloatNaN value

NegInf # function

Returns a negative infinity value

function : NegInf() ~ Float

Return

TypeDescription
Floatnegative infinity value

Pi # function

Value of Pi

function : Pi() ~ Float

Return

TypeDescription
Floatvalue of Pi

Example

area := Float->Pi() * 5.0 * 5.0;
"Circle area: {$area}"->PrintLine();

Pow # function

Calculates the power value

function : Pow(b:Float, r:Int) ~ Float

Parameters

NameTypeDescription
bFloatpower base
rIntpower to raise

Return

TypeDescription
Floatpseudo power value

Pow # function

Calculates the power value

function : Pow(b:Float, r:Float) ~ Float

Parameters

NameTypeDescription
bFloatpower base
rFloatpower to raise

Return

TypeDescription
Floatpseudo power value

Example

Float->Pow(2.0, 8.0)->PrintLine();  # 256.0

Print # function

Prints value

function : Print() ~ Nil

PrintLine # function

Prints value with newline

function : PrintLine() ~ Nil

PrintLine # native

Prints values

function : native : PrintLine(v:Float[]) ~ Nil

Parameters

NameTypeDescription
vFloatvalues to print

PrintLine # native

Prints values

function : native : PrintLine(v:Float[,]) ~ Nil

Parameters

NameTypeDescription
vFloatvalues to print

Random # function

Returns a pseudo random value between 0.0 and 1.0, inclusive

function : Random() ~ Float

Return

TypeDescription
Floatpseudo random value

Example

r := Float->Random();
"Random 0–1: {$r}"->PrintLine();

Random # function

Returns a pseudo random value between 0.0 and max, inclusive

function : Random(max:Float) ~ Float

Parameters

NameTypeDescription
maxFloatmaximum value

Return

TypeDescription
Floatpseudo random value

Example

r := Float->Random(100.0);
"Random 0–100: {$r}"->PrintLine();

Random # function

Returns a pseudo random value between 0.0 and 1.0, inclusive

function : Random(range_start:Float, range_end:Float) ~ Float

Parameters

NameTypeDescription
range_startFloatminimum value
range_endFloatmaximum value

Return

TypeDescription
Floatpseudo random value

Round # function

Rounds the value

function : Round() ~ Float

Return

TypeDescription
Floatrounded value

Example

Float->Round(3.7)->PrintLine();  # 4.0

Sign # function

Returns the sign of a number

function : Sign() ~ Float

Return

TypeDescription
Floatsign of a number

Sin # function

Calculates the sine value

function : Sin() ~ Float

Return

TypeDescription
Floatsine value

Example

angle := Float->Pi() / 6.0;
Float->Sin(angle)->PrintLine();  # 0.5

Sinh # function

Calculates the hyperbolic sine

function : Sinh() ~ Float

Return

TypeDescription
Floathyperbolic sine value

Sqrt # function

Calculates the square root value

function : Sqrt() ~ Float

Return

TypeDescription
Floatsquare root value

Example

Float->Sqrt(16.0)->PrintLine();  # 4.0

Tan # function

Calculates the tangent value

function : Tan() ~ Float

Return

TypeDescription
Floattangent value

Example

angle := Float->Pi() / 4.0;
Float->Tan(angle)->PrintLine();  # ~1.0

Tanh # function

Calculates the hyperbolic tangent

function : Tanh() ~ Float

Return

TypeDescription
Floathyperbolic tangent value

ToByte # function

Returns the Character value

function : ToByte() ~ Byte

Return

TypeDescription
Bytevalue

ToChar # function

Returns the Int value

function : ToChar() ~ Char

Return

TypeDescription
Charvalue

ToDegrees # function

Converts the value into degrees

function : ToDegrees() ~ Float

Return

TypeDescription
Floatdegree value

ToInt # function

Returns the Int value

function : ToInt() ~ Int

Return

TypeDescription
Intvalue

Example

Float->ToInt(9.99)->PrintLine();  # 9

ToRadians # function

Converts the value into radians

function : ToRadians() ~ Float

Return

TypeDescription
Floatradian value

ToString # native

Returns a string representation of the value

function : native : ToString() ~ String

Return

TypeDescription
Stringstring representation of the value

Example

s := Float->ToString(3.14);
s->PrintLine();  # 3.14

ToString # function

Returns a fixed-point string representation of the float with a given number of decimal places (rounded). Used by string-interpolation format specifiers, e.g. "{$pi:.2}".

function : ToString(value:Float, precision:Int) ~ String

Parameters

NameTypeDescription
valueFloatfloat value
precisionIntnumber of decimal places (negative is treated as 0)

Return

TypeDescription
Stringfixed-point string representation

Example

Float->ToString(3.14159, 2)->PrintLine();  # 3.14

ToString # function

Returns a string representation of the float array

function : ToString(v:Float[,]) ~ String

Parameters

NameTypeDescription
vFloatfloat array

Return

TypeDescription
Stringstring representation of the float array

Trunc # function

Truncates the value

function : Trunc() ~ Float

Return

TypeDescription
Floattruncated value