Thread View: net.lang.c++
1 messages
1 total messages
Started by kenny
Thu, 25 Sep 1986 18:45
Hex bombs on negative argument
Author: kenny
Date: Thu, 25 Sep 1986 18:45
Date: Thu, 25 Sep 1986 18:45
19 lines
1309 bytes
1309 bytes
On a VAX, the following program dies horribly under version 1.0:
------------------------------------------------------------------------
#include <stream.h>
main (int argc, char *argv[]) {
int x = -1;
cout << hex (x, 8) << "\n";
}
------------------------------------------------------------------------
The problem is that in ``out.c'' the parameter ``i'' to the ``hex''
function is declared as long, but the conversion loop is a `` do { ...
} while (i>>=4);'' this is an endless loop for negative numbers.
Kevin Kenny UUCP: {ihnp4,pur-ee,convex}!uiucdcs!kenny
Department of Computer Science ARPA: kenny@B.CS.UIUC.EDU (kenny@UIUC.ARPA)
University of Illinois CSNET: kenny@UIUC.CSNET
1304 W. Springfield Ave.
Urbana, Illinois, 61801 Voice: (217) 333-7980
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