47 lines
1.4 KiB
Plaintext
47 lines
1.4 KiB
Plaintext
( ( rational2fixedpoint
|
|
= minus fixedpointnumber number decimals
|
|
. !arg:(#?number.~<0:~/#?decimals)
|
|
& ( !number:0&"0.0"
|
|
| ( !number:>0&
|
|
| -1*!number:?number&"-"
|
|
)
|
|
: ?minus
|
|
& !number+1/2*10^(-1*!decimals):?number
|
|
& !minus div$(!number.1) ".":?fixedpointnumber
|
|
& whl
|
|
' ( !decimals+-1:~<0:?decimals
|
|
& !fixedpointnumber
|
|
div$(mod$(!number.1)*10:?number.1)
|
|
: ?fixedpointnumber
|
|
)
|
|
& str$!fixedpointnumber
|
|
)
|
|
)
|
|
& ( fixedpoint2rational
|
|
= integerpart fractionalpart decimals
|
|
. @( !arg
|
|
: #?integerpart
|
|
( "." ?fractionalpart
|
|
| &0:?fractionalpart
|
|
)
|
|
)
|
|
& @(!fractionalpart:? #?fractionalpart [?decimals)
|
|
& !integerpart
|
|
+ (!integerpart:<0&-1|1)
|
|
* 10^(-1*!decimals)
|
|
* !fractionalpart
|
|
)
|
|
& whl
|
|
' ( put$"Enter Kelvin temperature:"
|
|
& fixedpoint2rational$(get'(,STR)):?kelvin
|
|
& !kelvin+-27315/100:?celcius
|
|
& (degree=.str$(chu$(x2d$b0) !arg))
|
|
& out$(rational2fixedpoint$(!kelvin.2) K)
|
|
& out$(rational2fixedpoint$(!celcius.2) degree$C)
|
|
& out$(rational2fixedpoint$(!celcius*9/5+32.2) degree$F)
|
|
& out$(rational2fixedpoint$(!kelvin*9/5.2) degree$Ra)
|
|
& out$(rational2fixedpoint$(!celcius*4/5.2) degree$Ré)
|
|
)
|
|
& done!
|
|
)
|