🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #104

Re: Optimization by programmers

#104
From: Anton Ertl
Date: Wed, 14 Oct 2026 08:02
49 lines
3901 bytes
Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
>On 2026-10-13 13:27, Anton Ertl wrote:
>> Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
>>> Forth originated in astronomy, if I remember correctly. I do remember
>>> that in an astronomy-domain Forth program, where it was often necessary
>>> to transform the celestial coordinates of stars from the standard
>>> catalog epoch (the start of the year 1950) to the current time, the word
>>> 1950.0 was defined to perform that transformation.
>> 
>> That is unlikely, as explained below.
>
>I am rather sure that my memory is correct.
>
>> In early systems fixed-point was used a lot, and 1950.0 is
>> interpreted as 19500 with a scale factor of 1/10.
>The Forth program in question represented angles as fixed-point 
>fractions (0 <= x < 1) of a full circle. I don't remember the number of 
>bits used.

Yes, that was customary for angles, as mentioned in the HOPL-II paper
"The Evolution of Forth"
<https://www.forth.com/resources/forth-programming-language/>:

|Moore expressed angles internally as 14-bit, 15-bit or 30-bit
|fixed-point binary fractions.

>Even if that Forth system by default interpreted 1950.0 as a double-cell 
>number, apparently it was still possible to override that interpretation 
>by defining a word called 1950.0.

Sure it's possible, but there is no reason why one would call a
conversion word 1950.0.  What would have been more in line with
practice is to define a word 1950.0 which does what writing 1950.0
without such a word does (if the BASE is right): to push a double-cell
number 19500.  The benefit of defining such a word in an
indirect-threaded code implementation (usual for Forth in those times)
is that invoking the word costs only one cell, whereas a double-cell
constant costs 4 cells.  The word amortizes its memory once more than
three occurences are in play.

The disadvantage of doing that for numbers with more than one digit is
that the BASE no longer influences the number that is pushed by
writing 1950.0.  But it can easily be that, for this application, this
was acceptable.  EPOCH still might have been a better name, though.

- anton
-- 
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
  Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID: <2026Oct14.100238@mips.complang.tuwien.ac.at>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <1177fdi$26ea4$1@dont-email.me> <11a5hd5$4qb$1@reader2.panix.com> <11a5lqo$2v5bq$1@dont-email.me> <11a6870$41j$1@reader2.panix.com> <11a6a6h$37i1n$1@dont-email.me> <1791742457-5857@newsgrouper.org> <11agm4p$2tfut$1@dont-email.me> <11ahs8q$38ir0$4@dont-email.me> <11aig3c$3hdcn$1@dont-email.me> <11aiqc0$3kr94$3@dont-email.me> <2026Oct12.191033@mips.complang.tuwien.ac.at> <nj6aehFiusqU1@mid.individual.net> <2026Oct13.122712@mips.complang.tuwien.ac.at> <nj76d2FnesuU1@mid.individual.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Optimization by programmers
Date: Wed, 14 Oct 2026 08:02:38 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 49
Message-ID: <2026Oct14.100238@mips.complang.tuwien.ac.at>
References: <1177fdi$26ea4$1@dont-email.me> <11a5hd5$4qb$1@reader2.panix.com> <11a5lqo$2v5bq$1@dont-email.me> <11a6870$41j$1@reader2.panix.com> <11a6a6h$37i1n$1@dont-email.me> <1791742457-5857@newsgrouper.org> <11agm4p$2tfut$1@dont-email.me> <11ahs8q$38ir0$4@dont-email.me> <11aig3c$3hdcn$1@dont-email.me> <11aiqc0$3kr94$3@dont-email.me> <2026Oct12.191033@mips.complang.tuwien.ac.at> <nj6aehFiusqU1@mid.individual.net> <2026Oct13.122712@mips.complang.tuwien.ac.at> <nj76d2FnesuU1@mid.individual.net>
Injection-Date: Wed, 14 Oct 2026 08:15:16 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1317364"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19C50OH8DmfvGabPvQFDS5P"; posting-host="4798f8a33d7cba4f1cfb66046bec21f9"
Cancel-Lock: sha1:s+PYjWa78Xjg31Z6oIcUwcuitNg= sha256:uzrwloMQETCe0Idbr98HD4TbfKutLyO/IFA0oSwnV98=
	sha1:fNMGCHG7+kxVs2Xq1CVVd1WCMOk= sha256:1eVgL3RhtUyqaHLjTQ1s4SAtFUYuKKEegByaeMf1pig=
X-newsreader: xrn 10.11