Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Dumb Numbers

Author
Message
JerBil
20
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 13th Nov 2004 10:43
I suppose this is well known, but isn't it a bug? It certainly is annoying when you're writing a program with such values. -JerBil


1tg46
20
Years of Service
User Offline
Joined: 1st Feb 2004
Location: I dont know!
Posted: 13th Nov 2004 12:30
Bug reports forum?


Click the sig
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 13th Nov 2004 13:32
Code runs fine here. Most of those numbers can't be perfectly represented by float binary values. There are many posts about this already. It is the same with all programming languages (even c++) without custom math routines.

JerBil
20
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 13th Nov 2004 13:51
Thanks for the replys, guys.

VB prints all of them correctly, though I suppose it's
"corrected" internally, somehow.

-JerBil
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 13th Nov 2004 14:27
If all you are doing is printing numbers then convert them to strings and print them.


I do not have VB installed ATM but I remember it printing numbers correctly like that, but if you actually assigned those values to a variable and then printed the variables' values to the screen it would print the same as DBP.

Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 13th Nov 2004 20:09 Edited at: 13th Nov 2004 20:11
do a forum search for floating point precision, then search the web for the same subject, everybody gets this issue as a programmer, it`s just we are shielded from it by our apps and programs we normaly use (the programmers use routines to hide the errors and save themselves ten million "bug" reports on something that isn`t actualy a bug), it applies to all digital equipment, grab a calculator, divide 1 by 3, divide the answer by 10000, now multiply it by 10000 and then multiply by 3, do you see the answer as 1?, no need to answer that, I know you don`t , if you want numbers that calculate with precision then use numbers that fit into powers of two (1/2, 1/4, 1/8, 1/16, 1/32 etc) or their sums (1/2+1/4=3/4), using numbers like that will alow you get accurate answers as long as you don`t go off the end of the allocated bytes for that value

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
JerBil
20
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 13th Nov 2004 23:49 Edited at: 13th Nov 2004 23:57
Thanks, guys.
Lost in Thought, actually, VB shows the same results printed
directly or assigned to a variable. They have hidden it well.

The only thing I'm going on about with DBP is when I write
a program that needs 1.4, I don't think I should have to
write extra code to because DBP returns 1.39999997616...

This may be ok when doing 3dmaths...no, wait, I think it should
work better then, too. "What? you keep missing the target? well,
it's just a little math thing, no big deal."


-JerBil
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Nov 2004 01:02
try 0.390625 instead of 0.4, it`s very close and is made from numbers of base 2 (1/4+1/8+1/64), if you go to much higher precision you will use more bits than are allocated for single precision floats and get an error again (although you could add 1/128 = 0.3984325, I think thats allowable)

as for missing in 3d math, if you allow one world unit to equal 1 meter then an innacuracy of 1/1000th (1mm) is well within precision, you don`t seriously expect your players to shoot at something less than 1mm large do you ?

what you need to do is to stop thinking in decimal and start thinking in binary, then you will see where the machine is coming from, remember that computers just do what you tell em, the trick is in telling them to do it in a way that gets the result you want.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
JerBil
20
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 14th Nov 2004 03:43
Mentor, thanks.
I know you're right, but I just had to keep posting until showed my ignorance...

-JerBil
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Nov 2004 05:10
LOL I`m just gonna keep posting until someone realises I am ignorant as well, so far I have managed to fake "knowledgable" pretty good, no-one seems to have spotted me yet


Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.

Login to post a reply

Server time is: 2024-11-11 21:23:36
Your offset time is: 2024-11-11 21:23:36