Page 1 of 1

bigint arithmetic + - * / bug?

Posted: Sun Oct 27, 2013 9:07 am
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

Re: bigint arithmetic + - * / bug?

Posted: Sun Oct 27, 2013 9:31 am
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.

Re: bigint arithmetic + - * / bug?

Posted: Sun Oct 27, 2013 9:44 am
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

Re: bigint arithmetic + - * / bug?

Posted: Sun Oct 27, 2013 9:55 am
by Lutz
... added now to the first paragraph: http://www.newlisp.org/downloads/newlis ... ml#big_int