newlisp/qa-specific-tests/qa-longnum

34 lines
1.7 KiB
Text
Executable file

#!/usr/bin/newlisp
(unless bigint
(println "this version is not enabled for big integers")
(exit))
(set 'num 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890)
(println "1000 digit number num --->")
(println num)
(println)
(set 'cien 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890)
(set 'result (* num num))
(println "(* num num) --->")
(println result)
(println)
(println "sum of " (length result) " digits in result --->"
(apply + (map int (explode (chop (string result))))))
(println)
(unless (= num (/ result num))
(println "(/ result num) ---> " (/ result num))
(println ">>>>> ERROR in parsing big integers")
(exit)
)
(println ">>>>> parsing big integers SUCCESSFUL")
(exit)