sparc64/107130: conversion from long double to long giving incorrect values

Jim White crewman6 at gmail.com
Sat Dec 23 00:00:36 PST 2006


>Number:         107130
>Category:       sparc64
>Synopsis:       conversion from long double to long giving incorrect values
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-sparc64
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 23 08:00:30 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Jim White
>Release:        6.1-RELEASE
>Organization:
>Environment:
FreeBSD ultra.lan 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Mon Oct  9 03:58:10 UTC2006     root at ultra.lan:/usr/src/sys/sparc64/compile/SPARC64-JKW  sparc64
 (GENERIC kernel with ROOTDEVNAME set)
>Description:
Conversions from long double to long and long long where the long double is a negative number always result in a value -1.  This seems related to closed PR 55773,


>How-To-Repeat:
#include <stdio.h>
int main()
{
long double i;
  for (i=0;;i=i-1.0)
    printf("%Lf %d %ld %lld %f\n",i,(int)i,(long)i,(long long)i,(double)i);
  return 0;
}

Sample Output:
0.000000 0 0 0 0.000000
-1.000000 -1 -1 -1 -1.000000
-2.000000 -2 -1 -1 -2.000000
-3.000000 -3 -1 -1 -3.000000
-4.000000 -4 -1 -1 -4.000000
-5.000000 -5 -1 -1 -5.000000
-6.000000 -6 -1 -1 -6.000000
-7.000000 -7 -1 -1 -7.000000
-8.000000 -8 -1 -1 -8.000000
-9.000000 -9 -1 -1 -9.000000
-10.000000 -10 -1 -1 -10.000000

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-sparc64 mailing list