Xref: news2.mv.net comp.os.msdos.djgpp:3467 From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) Newsgroups: comp.os.msdos.djgpp Subject: Re: Use of random Date: 5 May 1996 16:39:18 GMT Organization: The National Capital FreeNet Lines: 27 Sender: ao950 AT freenet5 DOT carleton DOT ca (Paul Derbyshire) Message-ID: <4miljm$4ri@freenet-news.carleton.ca> References: <4mikhp$pa5 AT frodo DOT smartlink DOT net> Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) NNTP-Posting-Host: freenet5.carleton.ca To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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