Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> Unfortunately, sqrt(x) isn't very cheap.
You'd be surprised: sqrt is built-in on most modern hardware. On my
three-year-old workstation, sqrt(x) seems to take about 2.6ns. For
comparison, the pack_float version posted in
<CAJEAwVGdb92E-XKfMLN3cxM2BWbbA3rrffzDzg8Ki1H5iQEk2Q(at)mail(dot)gmail(dot)com>
takes 3.9ns (and draws multiple compiler warnings, too).
regards, tom lane