POV-Ray : Newsgroups : povray.general : bitwise_.. in funtions? Server Time
8 Aug 2022 22:19:16 EDT (-0400)
  bitwise_.. in funtions? (Message 1 to 6 of 6)  
From: ingo
Subject: bitwise_.. in funtions?
Date: 9 Jul 2022 05:38:11
Message: <XnsAECF765E095FEseed7@news.povray.org>
The scene below results in "Expected 'function identifier', } found 
instead".

Are the three bitwise_.. functions not usable in functions? Bug? Me?

Ingo

---%<---%<---%<---

#version 3.7;
global_settings{ assumed_gamma 1.0 }
#default{ finish{ ambient 0.1 diffuse 0.9 }} 

plane{ 
  <0,1,0>, 0 
  texture{ 
    pigment{ 
      function{bitwise_xor(x, y, z)}
    }
  }
}

light_source{< 3000,3000,-3000> rgb 1}

camera {
  angle 75
  location <0.0 , 3.0 ,-3.0>
  right x*image_width/image_height
  look_at  <0.0 , 1.0 , 0.0>
}

---%<---%<---%<---

-- 
https://ingoogni.nl


Post a reply to this message

From: Bald Eagle
Subject: Re: bitwise_.. in funtions?
Date: 9 Jul 2022 08:20:00
Message: <web.62c97261fd43e9001f9dae3025979125@news.povray.org>
Yikes.

I've tried all manner of things to correct the syntax or find a workaround, but
I can't even get the parser to recognize the expressions

#declare F1 = function {bitwise_and (x, y, z)}
#declare F2 = function {bitwise_or (x, y, z)}
#declare F3 = function {bitwise_xor (x, y, z)}

SO, I'm thinking that the problem is that somehow those built-in function
identifiers never got put in a list to get passed to the (separate) function
parser.   Oof.

Which means that until that gets fixed, you're going to have to roll your own
user-defined functions in SDL.  :(  I recall doing this somewhere, when I didn't
know that our bitwise operators were spelled-out function identifiers and not
the usual symbols.
I can go hunt that down if you need me to...


https://stackoverflow.com/questions/7199625/mathematical-equation-for-and-bitwise-operation

(a & b)
can be done with:

(((a/1 % 2) * (b/1 % 2)) * 1) +
(((a/2 % 2) * (b/2 % 2)) * 2) +
(((a/4 % 2) * (b/4 % 2)) * 4) +
....
(((a/n % 2) * (b/n % 2)) * n)
Where n is 2 to the number of bits that A and B are composed minus one. This
assumes integer division (remainder is discarded).


Post a reply to this message

From: ingo
Subject: Re: bitwise_.. in funtions?
Date: 9 Jul 2022 09:43:20
Message: <XnsAECF9FED5F70Cseed7@news.povray.org>
in news:web.62c97261fd43e9001f9dae3025979125@news.povray.org Bald Eagle 
wrote:

> Yikes.

Yes.

I'll make a bugreport of it.
Doing my own in SDL is not important now, was just fiddling around.

Thanks.

-- 
https://ingoogni.nl


Post a reply to this message

From: jceddy
Subject: Re: bitwise_.. in funtions?
Date: 9 Jul 2022 12:15:00
Message: <web.62c9a94afd43e900864166f75d51d79c@news.povray.org>
>       function{bitwise_xor(x, y, z)}

I don't think this a bug so much as unsupported. Just FYI, it should probably be
a feature request rather than a bug report.

Also, the documentation says that these functions treat the inputs as integers.
Is that what you are expecting?


Post a reply to this message

From: jceddy
Subject: Re: bitwise_.. in funtions?
Date: 9 Jul 2022 12:25:00
Message: <web.62c9aabafd43e900864166f75d51d79c@news.povray.org>
"jceddy" <jce### [at] gmailcom> wrote:
> >       function{bitwise_xor(x, y, z)}
>
> I don't think this a bug so much as unsupported. Just FYI, it should probably be
> a feature request rather than a bug report.
>
> Also, the documentation says that these functions treat the inputs as integers.
> Is that what you are expecting?

Bald Eagle is exactly right as to why this isn't working, BTW.
For function{} there is a separate function parser that is pretty restrictive,
and it will not support calling things like bitwise_xor(), trace(), etc. It only
supports numerical values, operators, variables/parameters, and references to
other defined function names. So for this to work, someone would need to define
a "built-in" f_bitwise_xor function (for example), that you could then call in
function blocks.

You would indeed need to "roll your own" using only operators and simple
variables.


Post a reply to this message

From: ingo
Subject: Re: bitwise_.. in funtions?
Date: 9 Jul 2022 12:45:42
Message: <XnsAECFBED8C723Dseed7@news.povray.org>
in news:web.62c9a94afd43e900864166f75d51d79c@news.povray.org jceddy wrote:

> I don't think this a bug so much as unsupported.

Yes, you may be right. They are mentioned in the numeric expression 
section but not in the functions section. :(

-- 
https://ingoogni.nl


Post a reply to this message

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