From this conversation in the Perl 6 IRC channel and a question posted by Martin Barth, I'm trying to reproduce this C code using the Perl6 NativeCall interface, which is used with that purpose. This is what I have tried:
use NativeCall;
my uint32 $num = .new;
my num32 $float = .new: Num(1.0);
sub memcpy(num32 $float, uint32 $num, int32 $size) is native('Str') { * };
memcpy($float,$num,4);
say $num;
This yields an error:
This type cannot unbox to a native integer: P6opaque, Any
Which I interpret as, well, you have declared this as an Integer, I can't turn it into raw memory so that it can be copied from here to there.
This was only a possible way of answering the more general question by Martin Barth: how to turn raw bytes into a floating point number. Maybe there's other way of doing that, but in any case I'd be curious to find out how to turn C programs into NativeCall equivalents.
Update: in the meantime, here's the original question this other post tries to be a solution for.