Test integerness: Difference between revisions
Content added Content deleted
(jq) |
No edit summary |
||
Line 542: | Line 542: | ||
All tests pass. |
All tests pass. |
||
=={{header|PicoLisp}}== |
|||
Pico Lisp uses as built in datatype scaled fixed-point numbers. Every number is stored an an Integer and is a non integer only relative to the scale use. For this example we assume that all numbers are generated with the same scale. This is the standard case. |
|||
<lang PicoLisp> |
|||
(de int? (N) |
|||
(= N (* 1.0 (/ N 1.0)))) #returns T or NIL |
|||
(de integer? (N) |
|||
(and (= N (* 1.0 (/ N 1.0))) N)) #returns value of N or NIL |
|||
(scl 4) #-> 4 |
|||
1.0 #-> 10000 |
|||
(int? 1.0) #-> T |
|||
(int? 1) #-> NIL # 1 with a scale of 4 is same as 0.0001 which is not an Integer |
|||
(int? -1.0) #-> T |
|||
(int? -0.0) #-> T |
|||
(int? "RE") #-> "RE" -- Number expected |
|||
(int? (*/ 2.0 1.0 3.0)) #-> NIL # 6667 is not an integer of the scale of 4, use of */ because of the scale |
|||
</lang> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
===version 1=== |
===version 1=== |