POV-Ray : Newsgroups : povray.unix : Re: Povray on Debian AMD64 : Re: Povray on Debian AMD64 Server Time
5 Jul 2024 13:58:43 EDT (-0400)
  Re: Povray on Debian AMD64  
From: Warp
Date: 27 Sep 2004 09:54:55
Message: <41581baf@news.povray.org>
Ross <rli### [at] everestkcnet> wrote:
> slightly o-t, but having never had to consider endian-ness in programs due
> to hardly ever using bit level operators. i always just assumed that you
> would have to use a >> 8 on some machines and a << 8 on other machines
> (though honestly it's something i never really think about)

  "a >> 8" is standardized to mean that 'a' is shifted so that the
eight least significant bits disappear and the 9th least significant
bit becomes the least significant one and so on.
  That is, if the system uses the 2's complement representation of
integers, "a >> 8" is equivalent to "a / 256".
  This has nothing to do with endianess.

  Even if in one system the machine opcode to do this would be
"shift right" and in another it's "shift left" (which afaik is not
the case in any system: afaik in all systems the shift operation
which decreases the number is called "shift right") there wouldn't
be any problem in making the C compiler perform the proper shift
operation for the >> operator.

  Trying to make the code "portable" by changing shifting operators
depending on the endianess of the target system will only break the
perfectly working program and make it nonfunctional.

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

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