Issue Details (XML | Word | Printable)

Key: PCC-342
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
pcc

cast float to unsigned long long results in zero

Created: 05/May/11 07:43 PM   Updated: 06/May/11 05:22 PM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386


 Description  « Hide
The following short program

#include <stdio.h>

int
main(int ac, char *av[])
{

        unsigned long long l;
        float f;

        f = 150.00;
        l = (unsigned long long)f;

        printf("f %f, l %llu\n", f, l);
        return 0;
}

when compiled with pcc will output

  f 150.000000, l 0

it can be seen that the value 150.00 has been converted to 0ULL

(casting to long long does work)


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 06/May/11 05:22 PM
Should work now. The x87 must be set to correct floating point size before doing arithmetic.