|
 |
ingo <ing### [at] tag povray org> wrote:
> in news:60620b36$1@news.povray.org Thorsten wrote:
>
> > You can just compute the two's complement inverse before output, and
> > you get what you want
> >
>
> Sorry Thorsten, I realy don't understand. Can we do it by example.
> I have a number, 4321 and it hast to written to a file as uint_32.
Here's how you can do it with sint32le and sint32be. This does it like Thorsten
indicated in his last post.
#version 3.7;
// #declare UnsignedInteger = 0; // 0x00000000
// #declare UnsignedInteger = 1; // 0x00000001
// #declare UnsignedInteger = pow(2, 31) - 1; // 0x7FFFFFFF
// #declare UnsignedInteger = pow(2, 31); // 0x80000000
// #declare UnsignedInteger = pow(2, 31) + 1; // 0x80000001
// #declare UnsignedInteger = pow(2, 32) - 1; // 0xFFFFFFFF
#declare UnsignedInteger = 4321; // 0x000010E1
// #declare UnsignedInteger = 1059986700; // 0x3F2E1D0C
// #declare UnsignedInteger = 4091728320; // 0xF3E2D1C0
#if (UnsignedInteger < pow(2, 31))
#declare N = UnsignedInteger;
#else
#declare N = UnsignedInteger - pow(2, 32);
#end // if
#debug concat("\n\n", str(N, 0, 0), "\n\n")
#fopen SomeFile "LitteEndian32.bin" write
#write (SomeFile, sint32le N)
#fclose SomeFile
#fopen SomeFile "BigEndian32.bin" write
#write (SomeFile, sint32be N)
#fclose SomeFile
#error "Finished"
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
 |