v2026.11.0
All Bundles
Bundle

Core runtime library providing primitive types (Bool, Byte, Char, Int, Float, String), the Ref wrappers and array helpers, and system utilities (console, files, threads, sockets). Collections are not here: they are in gen_collect.obl. 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

Copy # function

Copies elements between two float arrays, or within one: overlapping ranges copy as if through a temporary array. Raises an IndexError, which a try/on or ?-> region can recover from, when a range does not fit its array; nothing is copied then.

function : Copy(dest:Float[], dest_offset:Int, src:Float[], src_offset:Int, count:Int) ~ Nil

Parameters

NameTypeDescription
destFloatdestination array
dest_offsetIntfirst destination index
srcFloatsource array
src_offsetIntfirst source index
countIntnumber of elements to copy; zero copies nothing

Example

a := [1.0, 2.0, 3.0, 4.0]
Float->Copy(a, 1, a, 0, 3);  # shifts the first three elements right by one

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

Fill # function

Sets every element of an array to a value

function : Fill(array:Float[], value:Float) ~ Nil

Parameters

NameTypeDescription
arrayFloatarray
valueFloatvalue

Fill # function

Sets a range of array elements to a value. Raises an IndexError, which a try/on or ?-> region can recover from, when the range does not fit the array; nothing is set then.

function : Fill(array:Float[], value:Float, offset:Int, count:Int) ~ Nil

Parameters

NameTypeDescription
arrayFloatarray
valueFloatvalue
offsetIntfirst index
countIntnumber of elements to set; zero sets nothing

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

ToBytes # function

Returns the raw bytes of an array's values: 8 per value, little-endian, as they lie in memory. Byte->ToFloats reads them back.

function : ToBytes(values:Float[]) ~ Byte[]

Parameters

NameTypeDescription
valuesFloatvalues

Return

TypeDescription
Bytevalues->Size() * 8 bytes

ToBytes # function

Returns the raw bytes of a range of an array's values: 8 per value, little-endian. Raises an IndexError, which a try/on or ?-> region can recover from, when the range does not fit the array.

function : ToBytes(values:Float[], offset:Int, count:Int) ~ Byte[]

Parameters

NameTypeDescription
valuesFloatvalues
offsetIntfirst value's index
countIntnumber of values

Return

TypeDescription
Bytecount * 8 bytes

Example

bytes := Float->ToBytes([1.5, 2.5, 3.5], 1, 2);  # 16 bytes

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

ToShortString # function

Returns the shortest string that reads back (String->ToFloat) as exactly the same value. Unlike ToString, which always prints six decimals, nothing is lost: 1.2e-05 stays "1.2e-05" rather than "0.000012", and 0.1 + 0.2 shows as "0.30000000000000004". Exponents from -4 to 15 print in fixed notation with at least one decimal ("100.0", "0.0001"), others as "d.ddde+XX"; -0.0, "inf", "-inf" and "nan" keep their sign or name.

function : ToShortString(value:Float) ~ String

Parameters

NameTypeDescription
valueFloatfloat value

Return

TypeDescription
Stringshortest round-trip string representation

Example

Float->ToShortString(0.1)->PrintLine();     # 0.1
Float->ToShortString(1.0e-7)->PrintLine();  # 1e-07

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