Game Development Community

1 * 1 = 4.29497e+009

by Tom Bak · in Torque Game Builder · 07/25/2007 (6:51 pm) · 5 replies

Hi,

I stumbled across a bizarre script bug a while back. I've seen it in 1.1.3 and 1.5.1...

%foo = getRandom(70,100) < 50 ? 1 : -1;
echo( "%foo = " @ %foo );
echo( "%foo * 1 = " @ %foo * 1 );

The output generated is


%foo = -1
%foo * 1 = 4.29497e+009


%foo always evaluates to -1 from the conditional expression. But if it is multiplied by something the result is a gigantic number.

Anyone know what's up with this? It's not the end of the world but it'd still be nice to have fixed. :)

Thanks...

Tom

#1
07/25/2007 (10:27 pm)
Yeah, I get this bug too.
#2
07/25/2007 (10:56 pm)
Even more:
%foo1 = getRandom(70,100) < 50 ? 1 : -1;
   echo( "%foo = " @ %foo1 );
   echo( "%foo + 1 = " @ 1 + %foo1 );

The output:
%foo = -1
%foo + 1 = 4.29497e+009
#3
07/25/2007 (11:28 pm)
It's a bug issue with the Ternary, which is returning an unsigned int.

I would just do something like this instead of trying to fix the bug.

if(getRandom(70,100) < 50 )
   %foo = 1 ; 
else
  %foo  = -1 ;

Bug with Ternary

Aun.
#4
07/30/2007 (3:14 pm)
When I try going to that forum I get the following message:

Sorry, only members who have purchased the following products may access this discussion:

This has irked me for a while... Is it really necessary to lock out members from particular forums like this? Doesn't this really just do much more harm than good? :(

(sorry it's a little off topic)

Specifically, once I upgrade to the commercial version of TGB and begin modifying the source code, wouldn't the forums for TGE be relevant for what I am doing? I find that many answers to questions I have about the TGB source and TGE engine are not accessible to me (like this one) because I am locked out of the forum.

Anyone else want to chime in? :)

Tom
#5
08/03/2007 (12:51 pm)
Tom,

Being locked out of forums/TDN can be quite aggravating at times, especially since TGE and TGB are so closely related. What probably irks me more is that even though I own TGE 1.5 I'm still locked out of TGE 1.4 content, or that I can't buy certain content packs because they require a license to 1.4.

How does that make sense?