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 / Divide into Real value

Author
Message
RanQor
19
Years of Service
User Offline
Joined: 8th Jun 2007
Location:
Posted: 23rd Jul 2010 20:09
Why doesn't this work? It looks like it's outputting the result as an int instead of an real value. I would have assumed DBPro would "detect" the left side's type as a real type, and calculate the division accordingly, but it doesn't.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Jul 2010 20:26
You could always make "a" real too.



HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 23rd Jul 2010 20:28
or this



Dark Physics makes any hot drink go cold.
RanQor
19
Years of Service
User Offline
Joined: 8th Jun 2007
Location:
Posted: 23rd Jul 2010 21:19
@Grog
I cannot use that because the A var will contain a value larger than what a Real value can hold (not in this example, but in my actual program).
BTW, nice Sig.


@HowDo
Thanks HowDo. That works perfectly.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jul 2010 21:48
Quote: "A var will contain a value larger than what a Real value can hold"

Huh? Floats can hold much larger values than integers, albeit with less accuracy.

Anyway, that's how it works in DBPro, C or C++, VB.NET, C# and pretty much every language that I can think of, UNLESS the numbers are already held internally as floats or double floats in the language in question.

HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 23rd Jul 2010 22:37 Edited at: 23rd Jul 2010 22:37
incase anyone is wondering why,
if you do this b#=a*6 there be no float.
but
if you do this b#=a*6.0 it will return a float.

Dark Physics makes any hot drink go cold.
RanQor
19
Years of Service
User Offline
Joined: 8th Jun 2007
Location:
Posted: 26th Jul 2010 15:34 Edited at: 26th Jul 2010 15:56
Quote: "Huh? Floats can hold much larger values than integers, albeit with less accuracy."


Your right, I misread the documentation.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 26th Jul 2010 15:38 Edited at: 26th Jul 2010 15:41
You ignored the E +/- 38 bit

E = times 10 to the power of

So:
±3.4*10^±38

REAL would be a bit useless otherwise!

It's difficult to visualise that, hence the "7 digits" in brackets, which means that you can represent numbers of almost any size, but only to 7 significant figures accuracy.

[b]
RanQor
19
Years of Service
User Offline
Joined: 8th Jun 2007
Location:
Posted: 26th Jul 2010 15:58
Yeah, I misread the documentation. I was wondering why that was so low.

Login to post a reply

Server time is: 2026-07-25 05:32:40
Your offset time is: 2026-07-25 05:32:40