1e+191e19
1e1910000000000000000000
Interestingly a flag strict_iso could solve a few
vexing problems. For example the ISO core standard
did only mention floor/1 with signature F → I.
So in GNU Prolog I can do:
/* GNU Prolog 1.5.0 */
?- current_prolog_flag(strict_iso, X).
X = on
yes
?- X is floor(1).
uncaught exception: error(type_error(float,1),(is)/2)
?- set_prolog_flag(strict_iso, off).
yes
?- X is floor(1).
X = 1
yes
A few Prolog systems don’t share the above behavior,
like SWI-Prolog for example doesn’t throw the type error.
Also SWI-Prolog has nowhere a flag strict_iso.
Currently I have changed my Prolog system to tell me:
/* Dogelog Player 1.3.1 */
?- current_prolog_flag(strict_iso, X).
X = off.
Hi,
Somehow I have the feeling it doesn't make
sense to only recognize floating point numbers
as number literals that have a period in it.
Most programming languages I have encountered
also recognize floating point numbers when
they have an exponent e or E in it:
- Python:
1e+191e19
- JavaScript:
1e1910000000000000000000
JavaScript is a little special. Since it has a
integer subset inside there floating point numbers.
Now I find that SWI-Prolog also allows 1e19:
/* SWI-Prolog 9.3.20 */
?- X = 1e19.
X = 1.0e+19.
I think this is a good idea. Since there is no
confusion. Most Prolog systems I checked never
alias an operator e with a number:
/* SWI-Prolog 9.3.20 */
?- op(500,yfx,e).
true.
?- X = 1 e 2.
X = 1 e 2.
Bye
Mild Shock schrieb:
Interestingly a flag strict_iso could solve a few
vexing problems. For example the ISO core standard
did only mention floor/1 with signature F → I.
So in GNU Prolog I can do:
/* GNU Prolog 1.5.0 */
?- current_prolog_flag(strict_iso, X).
X = on
yes
?- X is floor(1).
uncaught exception: error(type_error(float,1),(is)/2)
?- set_prolog_flag(strict_iso, off).
yes
?- X is floor(1).
X = 1
yes
A few Prolog systems don’t share the above behavior,
like SWI-Prolog for example doesn’t throw the type error.
Also SWI-Prolog has nowhere a flag strict_iso.
Currently I have changed my Prolog system to tell me:
/* Dogelog Player 1.3.1 */
?- current_prolog_flag(strict_iso, X).
X = off.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,030 |
Nodes: | 10 (1 / 9) |
Uptime: | 203:10:26 |
Calls: | 13,341 |
Calls today: | 4 |
Files: | 186,574 |
D/L today: |
3,995 files (1,252M bytes) |
Messages: | 3,357,145 |