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

Returns

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

Returns

Real

Example

Real("1.1")  # 1.1

Methods

*(a:Real, b:Real)
Multiplication
+(a:Real, b:Real)
Addition
-(a:Real, b:Real)
Subtraction
/(a:Real, b:Real)
Division
<(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:4910
Convert to string, appropriate for using as argument to external process.

Automatically called by NGS for syntax

$(mycommand $num) # num is Real
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
inspect(r:Real) Source: stdlib.ngs:6007
Inspect Real

Returns

Lines with exactly one line
Int(r:Real)
Convert Real (floating) number to Int. Floating part is truncated.

Returns

Int
round(r:Real)
Round a number
Str(r:Real)
Convert Real to Str
trunc(r:Real)
Truncate a number