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:586
Get zero

Returns

0.0
Real(s:Str) Source: stdlib.ngs:2605
Surrounding whitespace is ignored.

Returns

Real

Example

Real("1.1")  # 1.1

Methods

*(a:Real, b:Real)
Multiplication
*(a:Int, b:Real) Source: stdlib.ngs:9647
Undocumented
*(a:Real, b:Int) Source: stdlib.ngs:9648
Undocumented
+(a:Real, b:Real)
Addition
+(a:Int, b:Real) Source: stdlib.ngs:9641
Undocumented
+(a:Real, b:Int) Source: stdlib.ngs:9642
Undocumented
-(a:Real, b:Real)
Subtraction
-(a:Int, b:Real) Source: stdlib.ngs:9643
Undocumented
-(a:Real, b:Int) Source: stdlib.ngs:9644
Undocumented
/(a:Real, b:Real)
Division
/(a:Int, b:Real) Source: stdlib.ngs:9645
Undocumented
/(a:Real, b:Int) Source: stdlib.ngs:9646
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:7203
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:2628
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:2626
Convert Real into JSON compatible data structure - number
pow(base:Real, exponent:Real) Source: stdlib.ngs:9614
Undocumented

Returns

base to the power of exponent

Example

pow(2, 10) == 1024
round(r:Real)
Round a number
sleep(seconds:Real) Source: stdlib.ngs:8910
Sleep for the given number of seconds, including the fractional part. Uses NANOSLEEP(2). When interrupted by a signal, sleeps for the remainder. Throws InvalidArgument if seconds is negative or NaN.

Returns

null

Example

sleep(0.5)
Str(r:Real)
Convert Real to Str
trunc(r:Real)
Truncate a number