FWIW, I’ll take PR’s for the PackUnpack distribution to make ‘f’ and ‘d’ work :-)
> On 19 Apr 2016, at 07:28, JuhiMarcel LangbroekTimmerman <mt195...@gmail.com> > wrote: > > Hi Kevin > > I've made something up for the time being. You can find it in the BSON > module. Look for the file lib/Document.pm6 and the subs encode-double and > decode-double. This code must be rewritten though for speed but at least it > works. > > Marcel > > P.s. I've seen that not all comments in the program are correct, so take > care. The information about the process can also be found on a wiki page > > On April 19, 2016 1:58:12 AM Kevin Pye <kevin....@gmail.com> wrote: > >> 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.