NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/52214: llround can't handle big but legal values
>Number: 52214
>Category: lib
>Synopsis: llround can't handle big but legal values
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri May 05 23:45:00 +0000 2017
>Originator: Hal Murray
>Release: 7.0.2
>Organization:
ntpsec.org
>Environment:
NetBSD bob3.example.com 7.0.2 NetBSD 7.0.2 (GENERIC.201610210724Z) amd64
>Description:
llround can't handle values like 0x10000000000000
That's the 53rd bit.
There are 53 bits of precision in a double, but a double
can hold integers (long long) up to 63 bits.
>How-To-Repeat:
Needs -lm
I've been using:
cc -O1 -Wall -Wstrict-prototypes -Wmissing-prototypes -g -o ll-bug ll-bug.c -lm
/* test case for llround */
#include <math.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int i;
for (i=40; i<62; i++) {
long long op1 = 1LL<<i;
double op2 = (double)(op1);
long long int op3 = llround(op2);
long long int op4 = (long long)op2;
printf("%16llx %16llx %16llx\n", op1, op3, op4);
}
return 0;
}
>Fix:
Home |
Main Index |
Thread Index |
Old Index