Mail Archives: djgpp/1996/05/05/17:45:38
Nicholas Marrone (nmarrone AT smartlink DOT net) writes:
> Hullo,
> To test out my radix_bit_sort function, I've been trying to generate a
> list of random numbers to sort, and then sort them. The list is rather
> long, 4000, and I'd like it to be ints, but I can' seem to get it! The
> program compiles and runs without error, but it gives me #s far larger
> than integers when I print out some results. I'm using DJGPP v2.
In most DOS compilers (16-bit) int=short=2-byte integer.
In DJGPP (32-bit) int=long=4-byte integer.
Thus when you use "int" you might get unexpectedly huge numbers!
To ensure portability across compilers it would be necessary to never use
"int" but always "short" or "long". This eliminates uncertainty, and
peculiar surprises!
(I had a program that stored 2097152 integers in an array. I used "int". I
expected this to be four megabytes... what to my wondering eyes should
appear but
LSCAPE DAT 8388608 11.07.95 9:50 LSCAPE.DAT
)
--
.*. "Clouds are not spheres, mountains are not cones, coastlines are not
-() < circles, and bark is not smooth, nor does lightning travel in a
`*' straight line." ,------------------------------------------------
-- B. Mandelbrot | Paul Derbyshire (PGD) ao950 AT freenet DOT carleton DOT ca
- Raw text -