RosettaCode factorial needs to use longs

Russel Winder russel at winder.org.uk
Sun Mar 9 01:56:44 PST 2014


On Sat, 2014-03-08 at 21:20 +0000, bearophile wrote:
> Jay Norwood:
> 
> > http://rosettacode.org/wiki/Factorial#D
> >
> > to whomever is maintaining these:
> > Need to change all ints to longs in this example to get the 
> > displayed results since the 15! result requires more than 32 
> > bits.
> 
> I am maintaining the D entries, I have fixed that factorial code, 
> thank you. I don't know why the shown output was for 64 bit 
> numbers.

That page appears to quietly ignore the fact that those languages that
use hardware integers cannot correctly compute factorial(25), let alone
factorial(1000), at least assuming 64-bit integer hardware, whereas
those languages using hardware/software numbers as needed (e.g. Python,
etc.) have no problem.

And there doesn't seem to be mention of tail recursion and tail
recursion optimization much either. Pity really, these comparative pages
could be so useful but generally end up as dumping grounds.

Good to see the D examples being more careful about the internal vs
external iteration and recursion vs tail recursion issue.

I wonder though if it would be better to split the examples up rather
than have a single entry. Nothing to do with the code content just to do
with the visual perception. The D code looks big and so bad, whereas
those that split up the examples look small and so good. Can I suggest
partitioning the D entry into four sub entries so as to make it clear
that explicit iteration, implicit iteration, recursion and tail
recursion are all covered?

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140309/62a74c14/attachment-0001.sig>


More information about the Digitalmars-d-learn mailing list