9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Lyndon Nerenberg <lyndon@orthanc.ca>
To: Plan 9 from Bell Labs <9fans@9fans.net>
Subject: dc(1) exponent limits
Date: Mon, 16 Dec 2019 13:41:31 -0800	[thread overview]
Message-ID: <f4e540e1bbb930dc@orthanc.ca> (raw)

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

             reply	other threads:[~2019-12-16 21:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16 21:41 Lyndon Nerenberg [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4e540e1bbb930dc@orthanc.ca \
    --to=lyndon@orthanc.ca \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).