Overview

HTTPS SSH

inane

A little nonsense now and then is relished by the wisest men.

Overview

inane ("into NaN encoder") lets you encode single-precision floats into the unused portion of double-precision NaNs. Occasions on which this might be useful:

  • To confuse someone trying to debug your code
  • To confuse yourself trying to debug your code later
  • Birthday parties

See inane.wiki for API details.

Examples

NaN arithmetic

> (flonum-print-precision 7)
15
> (nanv (nan+ (nan 2) (nan 3)))
5.0
> (nanv (nan/ (nan 1) (nan 0)))
+inf.0
> (nanv (nan/ (nan 0) (nan 0)))
+nan.0
> (define nanpi (nan* (nan 4) (nanatan (nan 1))))
> nanpi
+nan.0
> (nanv nanpi)
3.141593

Count to NaN

> (define (count-to-nan n)
    (let loop ((i (nan n)))
      (if (nanzero? i)
          'done
          (begin
           (print i)
           (loop (nan- i (nan 1)))))))

> (count-to-nan 10)
+nan.0
+nan.0
+nan.0
+nan.0
+nan.0
+nan.0
+nan.0
+nan.0
+nan.0
+nan.0
done

Author

Jim Ursetto