[net.lang.c++] Hex bombs on negative argument

kenny@uiucdcsb.cs.uiuc.edu (09/25/86)

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