for ranges

Russel Winder via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 22 08:41:40 PST 2015


Playing with factorial implementations, as you do. I had a D
implementation using ulong. Not sensible obviously since overflow is a
bit of a problem. But the code worked, as did the tests. Now converting
to BigInt and…

The standard explicit iteration form uses a loop:

	for(i; 2..n+1)

for n = 0 or 1 this loop doesn't loop since the range is [,). However
for BigInt:

	for(i; two..n + one)

the loop starts at 0 and just keeps on going. This is clearly not good.

Am I having a mental breakdown or is this a real bug?


-- 
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/20150122/a8675d02/attachment.sig>


More information about the Digitalmars-d-learn mailing list