🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by mitch Mitchell N. Perilstein Wed, 30 Dec 1992 21:37
conversion from literal to double in 2.1
#1503
Author: mitch Mitchell N. Perilstein
Date: Wed, 30 Dec 1992 21:37
34 lines
1421 bytes
Conversion from int to double is working, but conversion from a literal
to a double is broken. gcc 2.1 on Sparc SunOS 4.1.2 and on RISC Ultrix
4.2 produces an unexpected result:

    convert int to double: -2147483648 -> -2147483648.000000
    convert lit to double: -2147483648 -> 2147483648.000000

I expected
    
    convert int to double: -2147483648 -> -2147483648.000000
    convert lit to double: -2147483648 -> -2147483648.000000

The vendor /bin/cc gave the second result on both platforms. Here is the
code. 

#define INT_MIN (-2147483648)	/* - (2^31) */

int main()
{
    double from_int, from_literal;
    int i;

    i = INT_MIN;
    from_int = i;
    printf("convert int to double: %d -> %f\n", i, from_int);

    from_literal = INT_MIN;
    printf("convert lit to double: %d -> %f\n", INT_MIN, from_literal);
}

Respectfully,
---
 Mitchell N. Perilstein   CAD Language Systems, Inc.   410-992-5700 x225 
 Member, League for Programming Freedom.  Mail lpf@uunet.uu.net for info.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads