Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Sven Barth
Am 14.08.2013 10:42, schrieb Vincent Snijders: 2013/8/14 Sven Barth > I wanted to write "x.5" instead of "0.5" :) For any digit x, it still can be represented exactly in binary representation ... *sigh* stupid floating point numbers... Regards, Sven

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Michael Schnell
On 08/14/2013 10:42 AM, Vincent Snijders wrote: For any digit x, it still can be represented exactly in binary representation ... Nope, As the bit count of the mantissa is limited to - say - n , with x > 2**(n-1) you will not have an exact representation of x.5. -Michael

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Vincent Snijders
2013/8/14 Sven Barth > I wanted to write "x.5" instead of "0.5" :) > > > For any digit x, it still can be represented exactly in binary representation ... Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/m

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Sven Barth
Am 14.08.2013 09:55, schrieb Michael Schnell: On 08/14/2013 09:38 AM, Sven Barth wrote: - 0.5 does not always have a direct representation as a floating point value and thus internally it might be 0.499 or something like that and thus it will be rounded to 0.4 (see also http://bugs.freep

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Sven Barth
Am 14.08.2013 10:11, schrieb Jonas Maebe: On 14 Aug 2013, at 09:38, Sven Barth wrote: - 0.5 does not always have a direct representation as a floating point value and thus internally it might be 0.499 or something like that and thus it will be rounded to 0.4 (see alsohttp://bugs.freepasc

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Jonas Maebe
On 14 Aug 2013, at 09:38, Sven Barth wrote: > - 0.5 does not always have a direct representation as a floating point value > and thus internally it might be 0.499 or something like that and thus it > will be rounded to 0.4 (see also http://bugs.freepascal.org/view.php?id=24374 > ) 0.5 is

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Michael Schnell
On 08/14/2013 09:38 AM, Sven Barth wrote: - 0.5 does not always have a direct representation as a floating point value and thus internally it might be 0.499 or something like that and thus it will be rounded to 0.4 (see also http://bugs.freepascal.org/view.php?id=24374 ) Hmmm AFAIU, in

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Sven Barth
Am 14.08.2013 08:38, schrieb Ludo Brands: On 08/14/2013 08:03 AM, Sven Barth wrote: Am 13.08.2013 23:48 schrieb "David Emerson" mailto:dle...@angelbase.com>>: Hi all, I have just discovered that the system.round function has this very odd behavior of rounding towards an even number when the f

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Sven Barth
Am 14.08.2013 08:47, schrieb David Emerson: Thanks for the suggestions, guys! José Mejuto wrote: > SimpleRoundTo I think. But I want an integer result, and this returns a floating point. Sven Barth wrote: Take a look at SetRoundMode in unit Math: http://www.freepascal.org/docs-html/rtl/math/s

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Sven Barth
Am 13.08.2013 23:47, schrieb David Emerson: Hi all, I have just discovered that the system.round function has this very odd behavior of rounding towards an even number when the fractional part is .5 -- in the system.round documentation this is described as "banker's rounding" I do not like

Re: [fpc-pascal] math round vs banker's round

2013-08-14 Thread Ludo Brands
On 08/14/2013 08:47 AM, David Emerson wrote: > > I don't see this TfpuRoundingMode mentioned anywhere in the > documentation, other than the "get" and "set" functions for the same. > What does it effect? > It sets the 8087 registers and or SSE registers in x86 and x64 systems. The problem is tha

Re: [fpc-pascal] math round vs banker's round

2013-08-13 Thread David Emerson
Thanks for the suggestions, guys! José Mejuto wrote: > SimpleRoundTo I think. But I want an integer result, and this returns a floating point. Sven Barth wrote: Take a look at SetRoundMode in unit Math: http://www.freepascal.org/docs-html/rtl/math/setroundmode.html After calling SetRoundMode

Re: [fpc-pascal] math round vs banker's round

2013-08-13 Thread Ludo Brands
On 08/14/2013 08:03 AM, Sven Barth wrote: > Am 13.08.2013 23:48 schrieb "David Emerson" >: >> >> Hi all, >> >> I have just discovered that the system.round function has this very > odd behavior of rounding towards an even number when the fractional part > is .5 -- in t

Re: [fpc-pascal] math round vs banker's round

2013-08-13 Thread Sven Barth
Am 13.08.2013 23:48 schrieb "David Emerson" : > > Hi all, > > I have just discovered that the system.round function has this very odd behavior of rounding towards an even number when the fractional part is .5 -- in the system.round documentation this is described as "banker's rounding" > > I do not

Re: [fpc-pascal] math round vs banker's round

2013-08-13 Thread José Mejuto
El 13/08/2013 23:47, David Emerson escribió: Hi all, I have just discovered that the system.round function has this very odd behavior of rounding towards an even number when the fractional part is .5 -- in the system.round documentation this is described as "banker's rounding" I do not like thi

[fpc-pascal] math round vs banker's round

2013-08-13 Thread David Emerson
Hi all, I have just discovered that the system.round function has this very odd behavior of rounding towards an even number when the fractional part is .5 -- in the system.round documentation this is described as "banker's rounding" I do not like this behavior. How can I use a more mathemat