[racket-dev] Sublinear functions of superfloat numbers

From: Neil Toronto (neil.toronto at gmail.com)
Date: Sat Jun 30 21:15:41 EDT 2012

I've noticed something interesting about the `log' function. Check out 
this interaction:

 > (real->double-flonum #e1e400)
 > (log #e1e400)

It's obviously not just converting to flonum first; it's likely doing 
some kind of argument reduction internally.

`sqrt' operates on superfloat numbers when they're perfect squares, and 
`sin' doesn't at all:

 > (sqrt #e1e400)
[1e200 written out]
 > (sqrt #e1e401)
 > (sin #e1e400)

I have two questions:

1. I think I have the Mad Skillz to make these work by wrapping the 
primitives with something that does argument reduction. Should I? (It 
should be especially interesting to do `sin', requiring an 
arbitrary-precision `pi' constant. Woo!)

2. Under what circumstances should sublinear `math' library functions do 
this? All of them?

Neil ⊥

Posted on the dev mailing list.