Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Determining the length of "long"?



# dominik.vogt@xxxxxx / 2014-09-11 22:36:08 +0100:
> Is there a way to determine the length of the C type long from
> inside a zsh script (without using external programs, of course).
> 
> As an alternative, is there a direct way to print out a "long"
> integer value as binary bytes in host byte order?
> 
> I.e. given a value, say 0x12345, I need to print that as
> 
>   \\x00\\x01\\x23\\x45
> 
> on a 32 bit platform, and as
> 
>   \\x00\\x00\\x00\\x00\\x00\\x01\\x23\\x45
> 
> on a 64 bit platform (possibly in reverse byte order, depending on
> the hardware).

see getconf(1)[0] and unistd.h(0P)[1], specifically
_POSIX_V6_ILP32_OFF32 and its brethren.

[0]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.html
[1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

-- 
roman



Messages sorted by: Reverse Date, Date, Thread, Author