bigint arithmetic + - * / bug?

For the Compleat Fan
Locked
steloflute
Posts: 13
Joined: Tue Nov 06, 2012 4:02 pm
Contact:

bigint arithmetic + - * / bug?

Post by steloflute »

arithmetic operators + - * / accept only 2 bigint arguments?

> (apply * (dup 2 10))
1024
> (* 2L 2L 2L)
4L
> (apply * (dup 2L 10))
4L
> (apply * (dup 2L 10) 2)
1024L

I think it is not consistent. cf.
> (* 2 2 2)
8

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: bigint arithmetic + - * / bug?

Post by Lutz »

Yes, big integer arithmetik operations only accept 2 parameters, as stated by the documentation. It has to be like this to keep newLISP small.

Use apply with a reduce parameter of 2 to work around this - as correctly shown in your example.

steloflute
Posts: 13
Joined: Tue Nov 06, 2012 4:02 pm
Contact:

Re: bigint arithmetic + - * / bug?

Post by steloflute »

Thank you for your reply!

Oh, the documentation.. It is in the examples. I think it should go to the main description. ^_^

; only 2 arguments are allowed in big integer operations
; apply with reduce parameter 2 guarantees 2 args at a time
; sequence itself does not take big integers, before using
; apply, the sequence is converted with bigint

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: bigint arithmetic + - * / bug?

Post by Lutz »

... added now to the first paragraph: http://www.newlisp.org/downloads/newlis ... ml#big_int

Locked