Deutsch   English   Français   Italiano  
<v6cl84$obt$2@dont-email.me>

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

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Krishna Myneni <krishna.myneni@ccreweb.org>
Newsgroups: comp.lang.forth
Subject: Re: exercise in double number arithmetic
Date: Sat, 6 Jul 2024 18:50:28 -0500
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <v6cl84$obt$2@dont-email.me>
References: <v6c8v0$3usoe$1@dont-email.me>
 <9c8e8993d3413e65caf355ecc6ceea31@www.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 07 Jul 2024 01:50:29 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ff7811a63fb4d5a12aa696e08a20351d";
	logging-data="24957"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18nF9O5e0ZeHXBRniVcpWXo"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:VKHq5adIcYUj7qt4bWtQ1PygmoU=
Content-Language: en-US
In-Reply-To: <9c8e8993d3413e65caf355ecc6ceea31@www.novabbs.com>
Bytes: 1751

On 7/6/24 16:59, Ahmed wrote:
> Why using double arithmetic when we can use simply Pascal triangle?
> ...

Yes! I had forgotten about Pascal's triangle when I coded my solution. A 
benefit of your double number solution is that it works on both 32-bit 
and 64-bit Forth systems.

Here's my solution for the specific problem, which will only work on a 
64-bit system:

: solution ( -- d)
     1 s>d 43 22 do i 1 m*/ loop d>f
     21 dup s>d rot 2 do I 1 m*/ loop d>f
     f/ fround f>d ;

We don't have D/ in the standard, which necessitated the conversion to 
float for dividing two double length numbers and then convert back to 
double.

--
Krishna