2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,7 +1,13 @@
|
|||
Programming languages have different ways of expressing floating-point literals. Show how floating-point literals can be expressed in your language: decimal or other bases, exponential notation, and any other special features.
|
||||
Programming languages have different ways of expressing floating-point literals.
|
||||
|
||||
|
||||
;Task:
|
||||
Show how floating-point literals can be expressed in your language: decimal or other bases, exponential notation, and any other special features.
|
||||
|
||||
You may want to include a regular expression or BNF/ABNF/EBNF defining allowable formats for your language.
|
||||
|
||||
See also [[Literals/Integer]].
|
||||
|
||||
Cf. [[Extreme floating point values]]
|
||||
;Related tasks:
|
||||
* [[Literals/Integer]]
|
||||
* [[Extreme floating point values]]
|
||||
<br><br>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
# floating point literals are called REAL denotations in Algol 68 #
|
||||
# They have the following forms: #
|
||||
# 1: a digit sequence followed by "." followed by a digit sequence #
|
||||
# 2: a "." followed by a digit sequence #
|
||||
# 3: forms 1 or 2 followed by "e" followed by an optional sign #
|
||||
# followed by a digit sequence #
|
||||
# 4: a digit sequence follows by "e" followed by an optional sign #
|
||||
# followed by a digit sequence #
|
||||
# #
|
||||
# The "e" indicates the following optionally-signed digit sequence is #
|
||||
# the exponent of the literal. #
|
||||
# If the implementation allows, a "times ten to the power symbol" #
|
||||
# can be used to replace "e" - e.g. a subscript "10" character #
|
||||
# #
|
||||
# spaces can appear anywhere in the denotation #
|
||||
# Examples: #
|
||||
REAL r;
|
||||
r := 1.234;
|
||||
r := .987;
|
||||
r := 4.2e-9;
|
||||
r := .4e+23;
|
||||
r := 1e10;
|
||||
r := 3.142e-23;
|
||||
r := 1 234 567 . 9 e - 4;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
1.0 // double
|
||||
1.234e-10 // double
|
||||
728832f // float
|
||||
728832F // float
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
6.02e23 # standard E notation
|
||||
:10<6.02 * 10 ** 23> # radix notation
|
||||
:5<11.002 * 10 ** 23> # exponent is still decimal
|
||||
:5<11.002*:5<20>**:5<43>> # all in base 5
|
||||
2e2 # same as 200e0, 2e2, 200.0e0 and 2.0e2
|
||||
6.02e23
|
||||
-2e48
|
||||
1e-9
|
||||
1e0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue