🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by mitch Mitchell N. Perilstein Sat, 02 Jan 1993 10:17
assignment from literal to double fails in 2.1
#1518
Author: mitch Mitchell N. Perilstein
Date: Sat, 02 Jan 1993 10:17
34 lines
1432 bytes
Assignment with type 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