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 / Evaluating DBpro - Question about simple maths

Author
Message
Roko
20
Years of Service
User Offline
Joined: 3rd Feb 2004
Location: California
Posted: 3rd Feb 2004 08:38
Greetings. After having a lot of success with 3Dcanvas, I am currently evaluating DBpro and trying to see if i can adapt to the syntactical structure; and have run into an interesting problem. In the code H1=50 and H2=100 and in therory, at least from what I was taught 50 divided by 100 is .5 and then multiplied by 100 should be 50. DBpro however always returns this test problem as 0 in the var HPp... Ive tried declaring HPp as a FLOAT, have tried using HPp#, tried this all on one formula line, apart (as you see it now) etc...

Is this a bug in the evaluation version of DBpro? Or am I missing something?
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 3rd Feb 2004 09:34 Edited at: 3rd Feb 2004 09:34
You need to force dbpro to use floats, this should work.


Unfortunatly there is noway to tell dbpro you want a float and it assumes integer maths unless there is a float in the calculation.
To force it to use floats you can put a .0 on the end of any number in the calculation or do what I did here and add 0.0 to one of the integer values.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Feb 2004 14:28
The rules are simple, and followed by the majority of compilers ..

int operation int -> int result
float operation int -> float result
int operation float -> float result
float operation float -> float result

Where operation is +, -, *, /

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
Roko
20
Years of Service
User Offline
Joined: 3rd Feb 2004
Location: California
Posted: 4th Feb 2004 03:56
Ah! Thank Ye! That did work.

Quote: "followed by the majority of compilers"


Actually, I've never encountered a compiler or interpreter that didnt automatically assume to use float for internal calculations. I'll just label it "British Maths" and file along with things like SET "American.Potatoe_Chips" = "British.Potatoe_Crisps" in my brain cells
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 4th Feb 2004 07:36
= "British.Crisps" (we don't include the word potato)

And remember SET "American.French_fries" = "British.Chips"

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home

Login to post a reply

Server time is: 2024-09-21 18:23:01
Your offset time is: 2024-09-21 18:23:01