At 12:58 -0700 8/4/07, chromatic wrote:
>On Wednesday 01 August 2007 13:50:45 Joshua Hoblitt wrote:
> > #include
>> #include
>>
>> int main ()
>> {
>> printf("0.0 : %f\n", 0.0);
>> printf("-0.0 : %f\n", -0.0);
>> printf("0.0 == -0.0 : %d\n", 0.0 == -0.0);
> > }
I'm afraid that would
On Wednesday 01 August 2007 13:50:45 Joshua Hoblitt wrote:
> I'm not sure if 0.0 == -0.0 is true on all platforms. It should be for
> IEEE754 compliance but in the real world...
>
> It might be nice to throw in a few tests to see if the example code
> below would have the same results on all plat
At 09:34 -0400 8/2/07, Andy Dougherty wrote:
> Guessing programmer intent doesn't seem to me to be an
>appropriate job for a virtual machine.
Agreed. But in engineering and science floating point tests are often buried
in deep loops. An operator for rapid testing of near-equal can help with
ex
On Thu, 2 Aug 2007, Joshua Isom wrote:
> I'm pretty sure 0.0 always equals -0.0. I think it's part of the c
> specification. Now, on OpenBSD, you can't print -0.0, as it will print 0.0
> instead which is really annoying. This is with at least 3.8 but I don't know
> if it's been changed since th
I'm pretty sure 0.0 always equals -0.0. I think it's part of the c
specification. Now, on OpenBSD, you can't print -0.0, as it will print
0.0 instead which is really annoying. This is with at least 3.8 but I
don't know if it's been changed since then. Anyway, to test for -0.0
instead of 0.0
I'm not sure if 0.0 == -0.0 is true on all platforms. It should be for
IEEE754 compliance but in the real world...
It might be nice to throw in a few tests to see if the example code
below would have the same results on all platforms.
--
#include
#include
int main ()
{
printf("0.0 : %f\n"
if the values you are storing in floats are known to be integers of a size less
then the mantissa for he floating type then exact comparisons work just as
expected. Storing 10 digit phone numbers as floats is an example of this.
There must be some way to access exact comparisons in the languag
At 18:32 + 7/31/07, peter baylies wrote:
>On 7/31/07, Paul Cochrane <[EMAIL PROTECTED]> wrote:
> > return (fabs(x - y) <= fabs(x + y)*EPSILON) ? 1 : 0;
>
>That may not be a bad idea, but I think there's a bug in that code --
>take, for example, the case where x and y both equal approximatel
> A couple of comments on dealing with floats.
>
> - Use FLT_EPSILON/DBL_EPSILON from float.h
>
> - You method is total overkill, return (fabs(x - y) < DBL_EPSILON ? 1 : 0);
> should be sufficent (note: check with a numerical expert).
This is what I thought in the beginning. However, whether on
On 31/07/07, Andy Lester <[EMAIL PROTECTED]> wrote:
>
> On Jul 31, 2007, at 1:32 PM, peter baylies wrote:
>
> > That may not be a bad idea, but I think there's a bug in that code --
> > take, for example, the case where x and y both equal approximately a
> > million (or more).
> >
> > Maybe you wan
On Jul 31, 2007, at 1:32 PM, peter baylies wrote:
That may not be a bad idea, but I think there's a bug in that code --
take, for example, the case where x and y both equal approximately a
million (or more).
Maybe you wanted this instead:
return (fabs(x - y) <= EPSILON) ? 1 : 0;
The RE
d.
>
>
> -J
>
> --
> On Tue, Jul 31, 2007 at 07:17:15PM +0200, Paul Cochrane wrote:
> > Hi all,
> >
> > I'm wanting to remove all the floating point comparison warnings which
> > appear when compiling parrot and wanted some advice as to how best to
On Tue, 31 Jul 2007, Paul Cochrane wrote:
> Hi all,
>
> I'm wanting to remove all the floating point comparison warnings which
> appear when compiling parrot and wanted some advice as to how best to
> achieve this.
>
> Floating point comparisons appear in code such a
> #define EPSILON 0.005
>
> INTVAL is_float_equal(FLOATVAL x, FLOATVAL y)
> {
> return (fabs(x - y) <= fabs(x + y)*EPSILON) ? 1 : 0;
> }
>
> (this code was adapted from equivalent fortran code given here:
> http://www.lahey.com/float.htm courtesy of part
On 7/31/07, Paul Cochrane <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm wanting to remove all the floating point comparison warnings which
> appear when compiling parrot and wanted some advice as to how best to
> achieve this.
>
> Floating point comparisons appear
Hi all,
I'm wanting to remove all the floating point comparison warnings which
appear when compiling parrot and wanted some advice as to how best to
achieve this.
Floating point comparisons appear in code such as (taken from src/string.c):
if (*p == '-' && f == 0.
16 matches
Mail list logo