Approximate equality: Difference between revisions

m
→‎{{header|R}}: Syntax highlighting.
m (→‎{{header|Phix}}: changed output format, undid 28/12/21 "fix" to printf())
m (→‎{{header|R}}: Syntax highlighting.)
Line 1,203:
=={{header|R}}==
The base library has the function all.equal() for this task. However, when the numbers are not equal, rather than return FALSE, it tries to explain the difference. To fix this, we use isTRUE(all.equal(....)) instead.
<lang rrsplus>approxEq<-function(...) isTRUE(all.equal(...))
tests<-rbind(c(100000000000000.01, 100000000000000.011),
c(100.01, 100.011),
Line 1,226:
Test 7: -2.000000000000000444089210 -2.000000000000000000000000 TRUE
Test 8: 3.141592653589793115997963 3.141592653589793115997963 TRUE</pre>
 
=={{header|Racket}}==
 
331

edits