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 / REAL number issue

Author
Message
cabbage
21
Years of Service
User Offline
Joined: 18th Jun 2003
Location: United Kingdom
Posted: 19th Jun 2003 02:04
First things first, im new to using a language where you have to specify the difference between integers and real numbers (yes its been that long :-s )

Im currently coding a matrix editor for DBPro and everything is going great, or was until the real number issue raised its head.

If I enter:

scale#=0.1 , scale# reports a value of 0.1

however if i enter:

scale#=variable_a/variable_b or just simply scale#=100/500 , everything starts to go pear shaped because scale# reports back as zero.

I need to have a scale in the code so that matrix sizes can be scaled up/down to make design possible (the matrices are being line drawn for ease of editing then heights, textures etc transposed onto a real matrix later on). Sounds wonkey but try the snippet to see what I mean

Any suggestions are greatly appreciated.
Misanthrope
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location:
Posted: 19th Jun 2003 02:11
Variable_a and Variable_b should be Variable_a# and Variable_b#, and initialized with floating-point numbers ("reals" in DB) so DB treats them as floats. Additionally, when you perform math operations on floats, do so with floats: scale# = 100.0/500.0

What you're seeing is probably DB treating those variables as whole integers, and fractional values less than 1 are being rounded down to zero.

-Misanthrope
cabbage
21
Years of Service
User Offline
Joined: 18th Jun 2003
Location: United Kingdom
Posted: 19th Jun 2003 02:25
Thanks

Adding the ".0" to the end of the constants did the job nicely!

Login to post a reply

Server time is: 2024-11-24 18:43:37
Your offset time is: 2024-11-24 18:43:37