|
-
May 7th, 2008, 10:52 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Double variables
Hi people.
I might have to do some more debugging on my code but... based on some tests, I'm having strange behabiours with "doubles".
I thought that this might be a general known "issue" and someone would bring up the main causes of that.
My problem is that if I do simple calculations, I end up with a trailing decimal at the 10th position of so.
Exemple: 27.8 - 27.7 will sometimes equal "0.100000000001"
I cound fix my problem my doing round(var,3), but this is just "patching", I don't like it quite much
any idea?
Thanks
-
May 7th, 2008, 10:55 AM
#2
Re: Double variables
That's just the way it is with Doubles. Use Currency instead unless you need more than 4 decimals.
-
May 7th, 2008, 10:57 AM
#3
Thread Starter
Hyperactive Member
Re: Double variables
I see. I usually need 3-4 decimals, not more. I'll have to check how many decimals "currency" allows.
Than you're suggesting to use currency, whatever the data I'm dealing with? In my case, it's not currency but quantities, I believe it makes no difference.
Thank you.
-
May 7th, 2008, 10:58 AM
#4
Re: Double variables
 Originally Posted by Krass
I see. I usually need 3-4 decimals, not more. I'll have to check how many decimals "currency" allows.
Than you're suggesting to use currency, whatever the data I'm dealing with? In my case, it's not currency but quantities, I believe it makes no difference.
Thank you.
I actually updated my post while you were posting to say that you can use up to 4 decimal places, and it doesn't matter if it's not actual currency.
-
May 7th, 2008, 11:00 AM
#5
Thread Starter
Hyperactive Member
Re: Double variables
Well that might solve quite a few problems on my side. Thanks for your quick input.
-
May 7th, 2008, 11:00 AM
#6
Re: Double variables
BTW displaying your email address in your signature may tend to attact spammers.
-
May 7th, 2008, 11:02 AM
#7
Thread Starter
Hyperactive Member
Re: [RESOLVED] Double variables
Yes I've been told this a couple of times. The thing is I don't care much about spams getting to THAT hotmail. And I like it when people pops in my live messenger for some coding chat.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|