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.

DarkBASIC Professional Discussion / How do I do math where a decimal fraction "should" be the result?

Author
Message
orv
22
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Chicago, IL
Posted: 30th Oct 2003 05:21
run this tiny bit of code:


it should return: 0.19625

but it returns: 0

this is not acceptable!!!

what do i need to do to get DBPro talking in fractions?

If you aim at nothing you'll hit it every time. 806mhz AMD Athlon Processor. 384MB memory.
Windows XP Home Edition. RADEON 9700 Pro graphics card. - editor.exe=1.0.6.1 - DBPCompiler.exe=V1.05
orv
22
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Chicago, IL
Posted: 30th Oct 2003 05:32
BINGO!

I found my problem with ol' DB Pro!

the clue was in the following thread I found:
http://www.thegamecreators.com/?m=forum_view&t=18952&b=7

the new (working) code is:


dbPro needs that ".0" on the end of the number to give it a (clue) that this is a fractional calculation. WEIRD!

but HEY! i got it working!!

If you aim at nothing you'll hit it every time. 806mhz AMD Athlon Processor. 384MB memory.
Windows XP Home Edition. RADEON 9700 Pro graphics card. - editor.exe=1.0.6.1 - DBPCompiler.exe=V1.05
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 30th Oct 2003 06:02
yeah, it seems declaring a float doesn't matter, it needs the .0 to give it a clue

-RUST-
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Oct 2003 09:31
... which is perfect correct. An integer divided by an integer gives an integer result. This is the way many languages I know do it (C, C++, Pascal - there are probably many others)
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 30th Oct 2003 12:48
what i find odd is things like this though...
return float = get maximum pixel shader value()

my GeForce4 returns 1.421, yet my FX returns 2
i know that it should be 2.0, but for some reason it doesn't print the numbers after it even though its returning a float.
though i think the print, text and string commands always want to just work with integers.

annoying though to work with


To Survive You Must Evolve... This Time Van Will Not Escape His Fate!
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 30th Oct 2003 13:49 Edited at: 30th Oct 2003 13:50
I think thats a 'problem' with PRINT/TEXT.
I supposed technically 2 (without the decimal value) is correct (as 2=2.0)


Avatar & Logo by Indi. Insert witty comment here...
Xander
23
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 30th Oct 2003 20:34
I have noticed that also, if your print a number, no matter if it is a floating point number, or an integer variable, it will always print an integer if the number is an exact integer (2.0 = 2)

But... Aren't there some commands that force the print command to use decimal points, maybe I am confusing DB with a different language...

Xander - Bolt Software

Why do the antagonists always have to look so cool?
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 30th Oct 2003 22:09
My MATH plug-in (VALF) may do it (cant remember now )


Avatar & Logo by Indi. Insert witty comment here...

Login to post a reply

Server time is: 2026-07-26 13:02:06
Your offset time is: 2026-07-26 13:02:06