FLOAT 1g 2023-04-17 laplante@plcb.ca GOWEB


title: “FLOAT Type” author: “Pierre Laplante laplante@plcb.ca” date: “2023-04-17” version: “1.0.0”

category: “GOWEB/Language”

Description

The FLOAT type represents a real number.
In mathematics, a real number is a value that can represent a quantity along a continuous line.

Real numbers include all rational numbers, such as integers (e.g., −5) and fractions (e.g., 43),
as well as all irrational numbers, such as √2 (1.41421356…, an irrational algebraic number) and π (3.14159265…, a transcendental number).

The internal representation of this type is similar to a float64 in the Go programming language.

Lexical Parser

LNUM            [0-9]+
DNUM            ([0-9]*[\.][0-9]+)|([0-9]+\.[0-9]*)
EXPONENT_DNUM   (({LNUM}|{DNUM})[eE][+-]?{LNUM})

float = {DNUM}|{EXPONENT_DNUM}

Examples

Example 1: Simple float

res={{ a := .56; a; }}.
return
res=0.56.

Example 2: Decimal number

res={{ a := 1.1; a; }}.
return
res=1.1.

Example 3: Standard float

res={{ a := 56.65; a; }}.
return
res=56.65.

Example 4: Exponent notation (positive)

res={{ a := 2.0e5; a; }}.
return
res=200000.

Example 5: Exponent notation (negative)

res={{ a := 2.0E-32; a; }}.
return
res=0.00000000000000000000000000000002.