F64 lib Updated.

Developed or developing a new product in PureBasic? Tell the world about it.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

F64 lib Updated.

Post by jack »

fixed the Round function (I hope) :)
added ExpTen
File:1->F64.zip
Image
Last edited by jack on Mon Sep 12, 2005 12:04 pm, edited 2 times in total.
upnorth
User
User
Posts: 18
Joined: Wed Jul 21, 2004 8:54 pm
Location: California, USA

Post by upnorth »

Thank you Jack! Your efforts are greatly appreciated.
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Re: F64 lib Updated.

Post by freedimension »

jack wrote:for those that use the F64 lib by freedimension
Don't be that decent, it's also your lib now. I only brought it to live and you are keeping it alive now ;-)
Great work btw. Couldn't figure out what was wrong on that bug (don't like C that much :D )
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

you are too kind, as my contribution is rather small. :oops:
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

jack wrote:you are too kind, as my contribution is rather small. :oops:
but nonetheless important to the community :)
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

thank you, btw i emailed the modified source code to you, compiles with MSVC 6. :)
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Howdy,

Shouldn't...

Code: Select all

a.double
b.double

F64_Val(a, "621.675000")
F64_Round(a, 2, b)
Debug F64_Str(b)
Return 621.68 and not 621.67? I'm using F64 version 0.95.

Great tool, by the way. Very very useful for me in many apps :)
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Hi Jack and thanx for updating this excellent lib wich i can't live without (really).
Keep up the good work :D
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

Xombie wrote: Shouldn't...

Code: Select all

a.double
b.double

F64_Val(a, "621.675000")
F64_Round(a, 2, b)
Debug F64_Str(b)
Return 621.68 and not 621.67?
the function F64_Round rounds the value up, so the result is correct.
thanks KarLKoX and Xombie for the compliments :)
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

That's what I mean. 621.675 when rounding to two decimal places the 5 should round 7 up to 8 right? So it should be 621.68, right? The code I posted returns 621.67 as if it's just returning two decimal places and not rounding at all.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

Sorry I misunderstood Xombie.
not sure it’s a bug, it seems to be standard practice to round-off if the fractional part is exactly 0.5
For example try this

Code: Select all

a.double 
b.double 

F64_Val(a, "621.675001") 
F64_Round(a, 2, b) 
Debug F64_Str(b) 
perhaps MrMath can shed some light on the subject?
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Could, perhaps, there be a roundUp() and a roundDown() function. Ceil() and Floor() or whatever?
@}--`--,-- A rose by any other name ..
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

There are already floor and ceiling functions but those will round up or down regardless of the fraction. I'm looking for a function that rounds down on a fraction like 1.1 to 1.4 while rounding up for 1.5 to 1.9.

@jack - Everything I've been taught since a kid is that you round up on 0.5 or greater. Excel does the same. "=ROUND(621.275,2)" will equal '621.28', rounding up on the 0.5.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

fixed the Round function (I hope) :)
added ExpTen
File:1->F64.zip
Image
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Might if be an idea to make two functions?

One that treats 0.5 as a round up (as I was taught in school) ..

.. and one that treats it as a round down.

For some reason - and I cannot recall why now - we used to add 0.49999' to a value and truncate. So 0.5 when down and anything above went up. I may have been to overcome an error in early MS FP (which was non-standard way back when in days of DOS) or it may have been to do with some financial calcs.

Anyhow, reason for suggesting two is that if there are two ways, the lib will always be doing it the wrong way for someone, whichever way you go.

Then again, maybe I'm talking cr@p. I just have this feeling, though.
@}--`--,-- A rose by any other name ..
Post Reply