9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* dc(1) exponent limits
@ 2019-12-16 21:41 Lyndon Nerenberg
  2019-12-16 22:46 ` [9fans] " Rob Pike
  0 siblings, 1 reply; 5+ messages in thread
From: Lyndon Nerenberg @ 2019-12-16 21:41 UTC (permalink / raw)
  To: Plan 9 from Bell Labs

While running some silly benchmarks I discovered dc's '^' operator
limits exponents to '9999'.  This seems arbitrary, perhaps a leftover
safety measure to keep things from eating all the CPU for days on
end on a slow machine?  I upped the limit to 99999 and the test
expression ran fine on a Pi4:

/n/dump/2019/1215.2/sys/src/cmd/dc.c:328,334 - dc.c:328,334
  				neg++;
  				chsign(arg1);
  			}
- 			if(length(arg1)>=3) {
+ 			if(length(arg1)>=4) {
  				error("exp too big\n");
  			}
  			savk = sunputc(arg2);

If you're feeling bored and apply the above patch, consider running
this mini-bench and mailing the output directly to me:

echo -n `{cat /dev/cputype}^' ** ' ; echo 652342 52342 '^' 34232342 / p q | time dc >/dev/null

It will take a while to run (50 minutes on the Pi4).

--lyndon

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-17  2:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-16 21:41 dc(1) exponent limits Lyndon Nerenberg
2019-12-16 22:46 ` [9fans] " Rob Pike
2019-12-16 22:47   ` Rob Pike
2019-12-17  2:28   ` Bakul Shah
2019-12-17  2:53     ` Bakul Shah

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).