35 lines
823 B
Text
35 lines
823 B
Text
(float2fraction=
|
|
integerPart decimalPart d1 dn exp sign
|
|
. @( !arg
|
|
: ~/#?integerPart
|
|
( &0:?decimalPart:?d1:?dn
|
|
| "."
|
|
[?d1
|
|
(|? 0|`)
|
|
( &0:?decimalPart
|
|
| ~/#?decimalPart:>0
|
|
)
|
|
[?dn
|
|
)
|
|
( &0:?exp
|
|
| (E|e) ~/#?exp
|
|
)
|
|
)
|
|
& ( !integerPart*(-1:?sign):>0:?integerPart
|
|
| 1:?sign
|
|
)
|
|
& !sign*(!integerPart+!decimalPart*10^(!d1+-1*!dn))*10^!exp
|
|
);
|
|
|
|
( out$float2fraction$"1.2"
|
|
& out$float2fraction$"1.02"
|
|
& out$float2fraction$"1.01"
|
|
& out$float2fraction$"10.01"
|
|
& out$float2fraction$"10.01e10"
|
|
& out$float2fraction$"10.01e1"
|
|
& out$float2fraction$"10.01e2"
|
|
& out$float2fraction$"10.01e-2"
|
|
& out$float2fraction$"-10.01e-2"
|
|
& out$float2fraction$"-10e-2"
|
|
& out$float2fraction$"0.000"
|
|
);
|