Real type

Real/Float type. Equivalent to the 'double' type in C

Direct parent types

Num
A number
Direct subtypes: 2

Constructors

Real(n:Int)
Convert Int to Real
Real() Source: stdlib.ngs:479
Get zero

Returns

0.0
Real(s:Str) Source: stdlib.ngs:2378
Convert a string to real (floating) number, inefficiently

Returns

Real

Example

Real("1.1")  # 1.1

Methods

*(a:Real, b:Real)
Multiplication
*(a:Int, b:Real) Source: stdlib.ngs:8838
Undocumented
*(a:Real, b:Int) Source: stdlib.ngs:8839
Undocumented
+(a:Real, b:Real)
Addition
+(a:Int, b:Real) Source: stdlib.ngs:8832
Undocumented
+(a:Real, b:Int) Source: stdlib.ngs:8833
Undocumented
-(a:Real, b:Real)
Subtraction
-(a:Int, b:Real) Source: stdlib.ngs:8834
Undocumented
-(a:Real, b:Int) Source: stdlib.ngs:8835
Undocumented
/(a:Real, b:Real)
Division
/(a:Int, b:Real) Source: stdlib.ngs:8836
Undocumented
/(a:Real, b:Int) Source: stdlib.ngs:8837
Undocumented
<(a:Real, b:Real)
Less-than comparison
<=(a:Real, b:Real)
Less-than-or-equal comparison
==(a:Real, b:Real)
Compare floating point numbers. Using this operator/function is not recommended.
>(a:Real, b:Real)
Greater-than comparison
>=(a:Real, b:Real)
Greater-than-or-equal comparison
Arg(x:Real) Source: stdlib.ngs:6572
Convert to string, appropriate for using as argument to external process.

Automatically called by NGS for syntax

$(mycommand $num) # num is Real
Bool(r:Real) Source: stdlib.ngs:2392
Undocumented
c_pow(base:Real, exponent:Real)
Raise to power

Example

c_pow(2.0, 10.0)  # [0, 1024]
c_pow(0.0, -1.0)  # [1, inf]
ceil(r:Real)
Ceil a number

Example

ceil(1.1)   # 2.0
ceil(-1.1)  # -1.0
floor(r:Real)
Floor a number

Example

floor(1.1)   # 1.0
floor(-1.1)  # -2.0
Int(r:Real)
Convert Real (floating) number to Int. Floating part is truncated.

Returns

Int
JsonData(r:Real) Source: stdlib.ngs:2390
Convert Real into JSON compatible data structure - number
pow(base:Real, exponent:Real) Source: stdlib.ngs:8805
Undocumented

Returns

base to the power of exponent

Example

pow(2, 10) == 1024
round(r:Real)
Round a number
Str(r:Real)
Convert Real to Str
trunc(r:Real)
Truncate a number