'
Comparatives
An Implementation of J
| ct | =: | 2^_44 | comparison tolerance | |
| teq | =: | |@- <:!.0 ct&*@>.&| | equal | |
| tne | =: | -.@teq | not equal | |
| tlt | =: | < !.0 *. tne | less than | |
| tgt | =: | > !.0 *. tne | greater than | |
| tle | =: | <:!.0 +. teq | less than or equal to | |
| tge | =: | >:!.0 +. teq | greater than or equal to | |
| tfloor | =: | <.!.0@(0.5&+) ([ - tgt) ] | floor | |
| tceil | =: | <.!.0@(0.5&+) ([ + tlt) ] | ceiling | |
| dsignum | =: | ct&<@| * 0&< - 0&> | signum (real) | |
| jsignum | =: | ct&<@| * (%|) | signum (complex) |
| fuzz | =: | 2^_44 | |
| int | =: | (-2^31)&<: *. <&(2^31) | |
| real | =: | {.@+. | |
| feq | =: | |@- <:!.0 fuzz&*@>.&| | |
| freal | =: | >:!.0 / @: ((fuzz,1)&*) @: | @: +. | |
| BfromD | =: | ]`(1&=) @. (feq 1&=) | |
| IfromD | =: | ]`<. @. (int *. (feq <.)) | |
| DfromZ | =: | ]`real @. (feq real) |