Sorry to be so long replying and thanking you for your help -- I've spent most of the last week in hospital with very limited communications.
Thank you -- lots of interesting information. I ended up for the moment with something like (retyping from memory)... method double { $!index += 8; nativecast((num64), Blob.new(@!bytes[ $index - 8 ..^ $index ] ); } which (summary to memory errors) is working fine, at least until I try to run the code on a machine with big-endian floats, when it will require some reversing of bytes, or a machine without IEEE floating point (do such machines still exist?) in which case Marcel's code could be very useful. By then perhaps there will have been consensus and implementation of a pack/unpack native solution for Perl 6. Thanks everybody. On 21 April 2016 at 01:47, mt1957 <mt1...@gmail.com> wrote: > > On 19-04-16 10:21, Elizabeth Mattijsen wrote: > >> FWIW, I’ll take PR’s for the PackUnpack distribution to make ‘f’ and ‘d’ >> work :-) >> > > Hi Elizabeth, > > For the PackUnpack distro this might come in handy... or might go in the > examples corner? > > Done some experiments and looks well. Please check the attachment for > encoding/decoding of doubles. decode-double has also an index in the buffer > to pull out a specific spot in the buffer where the encoded double should > be. The code is made from snippets from Timo Paulsen and > David Warren. > > You might want to know how much faster it has become. Well it's not that > much of an improvement, only encoding a double is about 4 times faster. > The decoding only 1.13 times. > > emulated encoded > 3000 runs total time = 7.211524 s, 0.002404 s per run, 416.000809 runs per > s > > native encoded > 3000 runs total time = 1.720918 s, 0.000574 s per run, 1743.256109 runs > per s > > emulated decode > 3000 runs total time = 1.038615 s, 0.000346 s per run, 2888.461538 runs > per s > > native decode > 3000 runs total time = 0.918133 s, 0.000306 s per run, 3267.498734 runs > per s > > > Before I pat myself on the back for the 'fast' emulated encode/decode > already in place in the BSON package the above results might mean that the > native routines can be done better. > > Regards, > Marcel > > >