Hi Marcel,
With regard to checking for endianess. I don't think there's anything built
in NativeCall that directly determines this, but hopefuly the following
should do it, without resorting to a C compiler.

use NativeCall;
sub little-endian returns Bool {
    my $i = CArray[uint32].new: 0x01234567;
    my $j = nativecast(CArray[uint8], $i);
    say sprintf("j[0]:%x j[3]:%x", $j[0], $j[3]);
    $j[0] == 0x67;
}

say "little-endian:" ~ little-endian;

I've only tested this on a little endian architecture.

Source: I ported the 'C' answer to this SO question:
http://stackoverflow.com/questions/12791864/c-program-to-check-little-vs-big-endian



On Tue, Apr 12, 2016 at 6:30 AM, Marcel Timmerman <mt1...@gmail.com> wrote:

> Hi
>
> Thanks for your answer. I was thinking in perl6, I should have been more
> explicit. At the moment I am converting Num to a float representation in
> my
> BSON module and was wondering if there where easier ways and maybe faster
> too.
>
> Regards,
> Marcel
>
>
>
>
>
>
> --- Forwarded message ---
> From: Marcel Timmerman <mt1...@gmail.com>
> Date: April 11, 2016 8:28:22 PM
> Subject: Re: Union
> To: Parrot Raiser <1parr...@gmail.com>
>
> Hi
> Thanks for your answer. I was thinking in perl6, I should have been more
> explicit. At the moment I am converting Num to a float representation in my
> BSON module and was wondering if there where easier ways and maybe faster
> too.
>
> Regards,
> Marcel
>
>
>
>
>

Reply via email to