bigint arithmetic + - * / bug?

Started by steloflute, October 27, 2013, 02:07:29 AM

Previous topic - Next topic

steloflute

arithmetic operators + - * / accept only 2 http://www.newlisp.org/downloads/newlisp_manual.html#big_int">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

#1
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

#2
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

#3
... added now to the first paragraph: http://www.newlisp.org/downloads/newlisp_manual.html#big_int">http://www.newlisp.org/downloads/newlis ... ml#big_int">http://www.newlisp.org/downloads/newlisp_manual.html#big_int