🔒 Locked
c++ -> Object Pascal
Advertisement
Original Post
His first one got killed by HTML, here it is again: (1<<VARIANCE_DEPTH)
That means "1 shifted left by the value of the macro (I assume it''s a macro/constant/whatever) VARIENCE_DEPTH", and is probably done at compile time. I don''t know Pascal, so I can''t help you out.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said

http://druidgames.cjb.net/
That means "1 shifted left by the value of the macro (I assume it''s a macro/constant/whatever) VARIENCE_DEPTH", and is probably done at compile time. I don''t know Pascal, so I can''t help you out.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said

http://druidgames.cjb.net/
For the first one. The difficult way of doing it is (forgive me, but my pascal is old and my brain is soggy).
Assume the C code reads like
X = (1<<VARIANCE_DEPTH);
INTEGER i,x;
...
i:=0;
x:=1;
REPEAT / LOOP (Gee... I haven''t done this for a while
)
x := x*2;
i := i+1;
UNTIL i >= VARIANCE_DEPTH
Ugly eh? But a bit shift is a multiple of 2. It all makes sense in the end
-Chris Bennett of Dwarfsoft - The future of RPGs
Thanks to all the goblins over in our little Game Design Corner niche
Assume the C code reads like
X = (1<<VARIANCE_DEPTH);
INTEGER i,x;
...
i:=0;
x:=1;
REPEAT / LOOP (Gee... I haven''t done this for a while
x := x*2;
i := i+1;
UNTIL i >= VARIANCE_DEPTH
Ugly eh? But a bit shift is a multiple of 2. It all makes sense in the end
-Chris Bennett of Dwarfsoft - The future of RPGs
or you could just use the 'shl' and 'shr' operators for bitshifting 
X := (1 shl VARIANCE_DEPTH);
return (d < 0) ? (-1) : (d > 0); is just an if-statement like previous posts mention, here's the object pascal code:
BTW: as far as i know, there's no such thing as inlining in object pascal, if there is i'd like to here about it...
Edited by - kvh on April 23, 2001 2:01:41 PM
X := (1 shl VARIANCE_DEPTH);
return (d < 0) ? (-1) : (d > 0); is just an if-statement like previous posts mention, here's the object pascal code:
|
BTW: as far as i know, there's no such thing as inlining in object pascal, if there is i'd like to here about it...
Edited by - kvh on April 23, 2001 2:01:41 PM
Okay... *grinZ*
the
x := 1 shl VARIANCE_DEPTH
is cool.
The second one can be improved slightly:
This works coZ Delphi also assigns 1 for true and 0 for false.
Edited by - LoreKeeper on April 24, 2001 4:44:08 AM
the
x := 1 shl VARIANCE_DEPTH
is cool.
The second one can be improved slightly:
|
This works coZ Delphi also assigns 1 for true and 0 for false.
Edited by - LoreKeeper on April 24, 2001 4:44:08 AM
Just came back to append what I said and mention SHL.. but looks like I was beaten to the punch... So what was it to do the loop? My Pascal skills are sooooo old and rusty
-Chris Bennett of Dwarfsoft - The future of RPGs
Thanks to all the goblins in the GDCorner niche
quote:
Original post by dwarfsoft
For the first one. The difficult way of doing it is (forgive me, but my pascal is old and my brain is soggy).
Assume the C code reads like
X = (1<
INTEGER i,x;
...
i:=0;
x:=1;
REPEAT / LOOP (Gee... I haven''t done this for a while)
x := x*2;
i := i+1;
UNTIL i >= VARIANCE_DEPTH
The loop would have been this:
var
i, x: Integer;
begin
i := 0;
x := 1;
while (i < VARIANCE_DEPTH) do
begin
x := x * 2;
i := i + 1;
end;
...
end;
Using a do..while loop would always execute the loop once, resulting in a minimum shift of one, ie. a minimum x value of 2. But what if the shift was to be zero, ie. x = 1? That is why I chose a while loop.
quote:
Ugly eh? But a bit shift is a multiple of 2. It all makes sense in the end![]()
Ugly, yes.
Steve ''Sly'' Williams Code Monkey Krome Studios
Cheers... Thanks for that.. I haven''t coded Pascal for almost 2 Years! Sheesh... Anyway, that has refreshed my memories of the good ol'' days of "Legend Of the Red Dragon" (LORD - by RTSoft) and all the Turbo Pascal IGMs *sigh*
-Chris Bennett of Dwarfsoft - The future of RPGs
Thanks to all the goblins in the GDCorner niche
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement