Deutsch   English   Français   Italiano  
<2025Jan3.105920@mips.complang.tuwien.ac.at>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: FP number syntax
Date: Fri, 03 Jan 2025 09:59:20 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 43
Message-ID: <2025Jan3.105920@mips.complang.tuwien.ac.at>
References: <f3d930ef062d020cd12825545af27eb8cccf9160@i2pn2.org> <0d58f9f2c2e7ce33f032cbda245a1eee4782552f@i2pn2.org> <874j2rpcl3.fsf@nightsong.com> <372725cbde75de8c5e4f86e726b42d159b3bba93@i2pn2.org> <nnd$7b8881e2$53ce8d75@a49c4f80952e91b8> <4f003a8611d814d648c2b1dca1ddc6b43b8537b7@i2pn2.org>
Injection-Date: Fri, 03 Jan 2025 11:19:39 +0100 (CET)
Injection-Info: dont-email.me; posting-host="70ac6a576408570545c4b35a96663a58";
	logging-data="4050340"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18oXcoCXOtjCslvhziI1m8r"
Cancel-Lock: sha1:GnG78lV2AhK575Niv6BoMWRzi2E=
X-newsreader: xrn 10.11
Bytes: 3056

dxf <dxforth@gmail.com> writes:
>Well, I consider mixed-math to be genius :)  Was it a Forth first -
>or it pre-existed in some language/system?

I am not aware of any other non-assembly language that supports
mixed-width math.  Some other programming languages have multiple
integer or FP widths, but they tend to define their operations as
first converting to a common width, and then producing a result of the
same width.  This can be used to specify widening operations, e.g., as
follows (in C):

int64_t widening_mul(int32_t a, int32_t b)
{
   return a * (int64_t)b;
}

but the compiler has to do extra work to recognize that this is a
widening multiplication (rather than first sign-extending the operands
and then performing a 64bit*64bit->64bit multiplication).

And for division there is no way to specify the likes of UM/MOD or
SM/REM in C such that it can be implemented with just the DIV or IDIV
instruction (plus maybe register-register moves) of IA-32 or AMD64.

Mixed-width multiplication and division is a natural outcome of
implementing multiplication and division using repeated addition,
subtraction and shifting, and of course the first PDP-11
implementation, the 8086, 68000 and MIPS R2000, which implemented
these operations internally in that way, provide mixed-width
instructions for them.

More recent CPUs use different implementation techniques, so recent
architectures tend not to provide mixed-width division instructions.
They tend to have support for mixed-width multiplication (but usually
split that into two instructions), probably because it's important for
implementing wide multiplication, which is important for cryptography.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: https://forth-standard.org/
   EuroForth 2024: https://euro.theforth.net