Page 1 of 2

F64 lib Updated.

Posted: Wed Jul 28, 2004 12:54 am
by jack
fixed the Round function (I hope) :)
added ExpTen
File:1->F64.zip
Image

Posted: Wed Jul 28, 2004 1:09 am
by upnorth
Thank you Jack! Your efforts are greatly appreciated.

Re: F64 lib Updated.

Posted: Wed Jul 28, 2004 9:52 am
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 )

Posted: Wed Jul 28, 2004 11:06 am
by jack
you are too kind, as my contribution is rather small. :oops:

Posted: Wed Jul 28, 2004 11:32 am
by freedimension
jack wrote:you are too kind, as my contribution is rather small. :oops:
but nonetheless important to the community :)

Posted: Wed Jul 28, 2004 11:50 am
by jack
thank you, btw i emailed the modified source code to you, compiles with MSVC 6. :)

Posted: Wed Sep 07, 2005 9:19 pm
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 :)

Posted: Wed Sep 07, 2005 10:01 pm
by KarLKoX
Hi Jack and thanx for updating this excellent lib wich i can't live without (really).
Keep up the good work :D

Posted: Thu Sep 08, 2005 12:19 am
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 :)

Posted: Thu Sep 08, 2005 3:11 am
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.

Posted: Thu Sep 08, 2005 9:29 am
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?

Posted: Thu Sep 08, 2005 2:48 pm
by Dare2
Could, perhaps, there be a roundUp() and a roundDown() function. Ceil() and Floor() or whatever?

Posted: Thu Sep 08, 2005 4:01 pm
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.

Posted: Sun Sep 11, 2005 5:39 pm
by jack
fixed the Round function (I hope) :)
added ExpTen
File:1->F64.zip
Image

Posted: Sun Sep 11, 2005 6:48 pm
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.