Hi,

I have a several-thousand-line long Perl 5 script which I've been
translating to Perl 6 over some time, and it runs fine, although a little
slowly :-)

There is however one section which I haven't needed to use until recently,
and which I've been avoiding translating because it's not all that easy. It
takes a binary blob out of a database and then unpacks it into various
structures.

This all works now, except that the blob contains several IEEE format
64-bit floating point numbers. The perl 5 code did a simple "unpack 'd',
$buffer", but none of the various pack/unpack implementations I can find
for Perl 6 handle floating point yet.

I can see a couple of possible of possible solutions:

1. Write perl code to rip apart the IEEE format and construct a new Real
which has the same value as the original number; or

2. Write a simple C function to take a pointer to a double and return the
double, put that into a shared library and then use NativeCall.

The first isn't as bad as it looks because the numbers are all of limited
range, and won't contain things like NaN and Inf so a general solution
isn't needed. I'm guessing the second would run more quickly.

Any other ideas?

Kevin.

Reply via email to