9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] factor.c bug (+ fix)
@ 2003-06-23 19:16 andrey mirtchovski
  0 siblings, 0 replies; only message in thread
From: andrey mirtchovski @ 2003-06-23 19:16 UTC (permalink / raw)
  To: 9fans

factor.c crashes (in _floatfmt) when given a sufficiently large number.

i've added a check similar to the one in primes.c that fixed the problem:


plan9% diff factor.c /sys/src/cmd/factor.c
7,8d6
< double	big = 9.007199254740992e15;
<
45,48d42
< 		if(n > big) {
< 			print("error: number too big\n");
< 			break;
< 		}
plan9%


that makes the program rather noisy, so it may be a good idea to
exits("number too big") instead of print()-ing the error message (the
program exits silently when given negative numbers, for example).

andrey



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-06-23 19:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-23 19:16 [9fans] factor.c bug (+ fix) andrey mirtchovski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).