|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Is it possible to do a Bitwise AND in SDL?
I can't find the word 'bit' anywhere in the help file, maybe I'm missing an
obvious synonym?
I want to test a series of bit flags, i.e.
#local myvar=13;
#if (myvar && 1)
//do bit flag 1 stuff
#end
== John ==
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Is it possible to do a Bitwise AND in SDL?
I'm pretty sure that's not possible. :-(
You can of course do stuff with the MOD() function to achive vaguely the
same effect, but I don't think POV-Ray lets you do it directly.
Andrew @ home.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
John D. Gwinner <joh### [at] cornelledu> wrote:
> Is it possible to do a Bitwise AND in SDL?
POV-Ray handles only flotaing point numbers.
Even though you can more or less simulate bit flags with floating
point numbers, it's not very feasible. And certainly there are no
bit operators for them.
Just use an array for your flags. It may take more memory, but you
are not having millions of flags, are you?-)
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Just use an array for your flags. It may take more memory, but you
> are not having millions of flags, are you?-)
Actually, just thought I'd mention... I tried doing this with strings
instead. (e.g., Flags = "zNcv" means only the Z-flag is set.)
I was then shocked to find that
#if (Flag = "Z")
gives me an error... it was later pointed out that
#if (asc(Flag) = asc("Z"))
works just fine. Weird... Anyway, I went this way because "nCV" is more
instantly understandable than 0x03. ;-) Just a thought...
Andrew @ home.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <406f258e@news.povray.org>, war### [at] tagpovrayorg says...
> John D. Gwinner <joh### [at] cornelledu> wrote:
> > Is it possible to do a Bitwise AND in SDL?
>
> POV-Ray handles only flotaing point numbers.
> Even though you can more or less simulate bit flags with floating
> point numbers, it's not very feasible. And certainly there are no
> bit operators for them.
>
> Just use an array for your flags. It may take more memory, but you
> are not having millions of flags, are you?-)
>
>
But.... Some mathematical operations require such operations.... Or at
least they can use them, so it is odd that such a thing is not actually
supported. Any method used to simulate this, where the result needs to be
used as a real numeric value would take extra steps to 'build' the value
from the array, string or whatever. This is imho quite silly.
--
void main () {
call functional_code()
else
call crash_windows();
}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> But.... Some mathematical operations require such operations.... Or at
> least they can use them, so it is odd that such a thing is not actually
> supported. Any method used to simulate this, where the result needs to be
> used as a real numeric value would take extra steps to 'build' the value
> from the array, string or whatever. This is imho quite silly.
True. But it would be possible. POV-Ray SDL is just a simple scripting
language provided for convenience; if you really need the speed that bit
operations can give you, then you're *probably* using the wrong language for
the job. You should consider writing a program in a different language which
outputs a POV-Ray SDL file which can be #included from your main one, to
provide the necessary data or objects.
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Patrick Elliott <sha### [at] hotmailcom> wrote:
> But.... Some mathematical operations require such operations....
Which ones for example?
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <407004ff@news.povray.org>,
Andrew C on Mozilla <voi### [at] devnull> wrote:
> I was then shocked to find that
> #if (Flag = "Z")
> gives me an error... it was later pointed out that
> #if (asc(Flag) = asc("Z"))
> works just fine. Weird... Anyway, I went this way because "nCV" is more
> instantly understandable than 0x03. ;-) Just a thought...
The equality operator expects numeric values, which strings aren't. Not
so weird, though scripting languages usually have better built-in
support for strings, POV Script isn't intended to do much string
processing. Anyway, that's an odd way of comparing strings, and only
works for single characters. This is the usual method:
#if(strcmp(Flag, "Z") = 0)
--
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <MPG.1ada23538462981989a0c@news.povray.org>,
Patrick Elliott <sha### [at] hotmailcom> wrote:
> But.... Some mathematical operations require such operations.... Or at
> least they can use them, so it is odd that such a thing is not actually
> supported. Any method used to simulate this, where the result needs to be
> used as a real numeric value would take extra steps to 'build' the value
> from the array, string or whatever. This is imho quite silly.
It is not silly. The scene language is a high level language, and has no
concept of bits, or even integers. Its numeric values are double
precision floats. Performing bitwise operations on these is generally a
bad idea, and is rarely useful. These operations are rarely used, and
nearly useless for POV-Ray scripts.
--
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Is it possible to do a Bitwise AND in SDL?
Yes, but not directly. Also note, that, as Warp pointed out, pov numbers
are floating point, so you might lose some bits if you use too many.
Untested suggestion:
// to extract bit K of N:
#macro Bit(K,N)
((floor(N/pow(2,K))) mod 2)
#end
// bitwise operations with K bits
#macro Not(N,K)
pow(2,K)-1-N
#end
#macro Nand(N,M,K)
#local I=0;
#local R=0;
#while (I<K)
#local R = R+(1-Bit(I,N)*Bit(I,M))*pow(2,I);
#local I = I+1;
#end
(R)
#end
#macro And(N,M,K)
Not(Nand(N,M,K),K)
#end
#macro Or(N,M,K)
Nand(Not(N,K),Not(M,K),K)
#end
#macro Xor(N,M,K)
And(Or(N,M,K),Nand(N,M,K),K)
#end
--
merge{#local i=-11;#while(i<11)#local
i=i+.1;sphere{<i*(i*i*(.05-i*i*(4e-7*i*i+3e-4))-3)10*sin(i)30>.5}#end
pigment{rgbt 1}interior{media{emission x}}hollow}// Mark Weyer
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|