bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

double type bug?


From: dryopithecus
Subject: double type bug?
Date: Sun, 14 Sep 2003 12:44:26 +0200

Hello.
I think I've found a bug related to the 'double' type. It seems that some
decimal constants are considered too large by glibc to fit in a signed double,
constants not really so high, but furthermore... if higher numbers than those
are used, there's no claim!!

Here is a little program for explanation. Below are the compiler warnings and
the console output.

----------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>

/* main */
int main (int argc, char *argv[])
{
  double a, b, c, d;

  a = -2147483648;
  b = -2147483649;
  c = -4294967296;
  d = 4294967297;

  printf("%.0f\n", a);
  printf("%.0f\n", b);
  printf("%.0f\n", c);
  printf("%.0f\n", d);

  return 0;
}

------------------------------------------------------------------------------
--
WARNINGS:
test.c:9: warning: decimal constant is so large that it is unsigned
test.c:10: warning: decimal constant is so large that it is unsigned

------------------------------------------------------------------------------
OUTPUT:
2147483648
2147483647
-4294967296
4294967297


Hope this helps...






reply via email to

[Prev in Thread] Current Thread [Next in Thread]