POV-Ray : Newsgroups : povray.advanced-users : write uint32_t : Re: write uint32_t Server Time
19 Apr 2024 04:39:26 EDT (-0400)
  Re: write uint32_t  
From: Tor Olav Kristensen
Date: 29 Mar 2021 13:35:00
Message: <web.60620e7f8cf934b8ae6f04a89db30a9@news.povray.org>
ingo <ing### [at] tagpovrayorg> wrote:
> The fine documentation states: "Note: Currently, unsigned 32-bit words are
> not supported."
>
> Guess what. I need those.
>
> Is there some trickery with 4 uint8' or 2 uint16le's to get the proper
> bytes in the proper place?

Hi Ingo

You can try this:

#version 3.7;

#declare AnInteger = 4091728320; // 0xf3e2d1c0

#declare R = AnInteger;
#declare Byte_0 = mod(R, 256);
#declare R = div(R, 256);
#declare Byte_1 = mod(R, 256);
#declare R = div(R, 256);
#declare Byte_2 = mod(R, 256);
#declare R = div(R, 256);
#declare Byte_3 = mod(R, 256);

#fopen SomeFile "LitteEndian.bin" write
#write (SomeFile, uint8 Byte_0)
#write (SomeFile, uint8 Byte_1)
#write (SomeFile, uint8 Byte_2)
#write (SomeFile, uint8 Byte_3)
#fclose SomeFile

#fopen SomeFile "BigEndian.bin" write
#write (SomeFile, uint8 Byte_3)
#write (SomeFile, uint8 Byte_2)
#write (SomeFile, uint8 Byte_1)
#write (SomeFile, uint8 Byte_0)
#fclose SomeFile

#error "Finished"

You can upload the resulting files to this web page: https://hexed.it
- and then inspect the results as both big endian and little endian integeres.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.