Srini
Srini

Reputation: 883

Clojure: Integer value ending with "N"

I have read about (*') function in clojure.

(*' 1234567890 9876543210)



Result: ;;=> 12193263111263526900N

I tried to execute this below

(*' 4535353535345345345 5675675675675675677 4564564646456645)

Result: ;;=> 117497352037570255927282105564555048448707485315089425N

What is "N" here? Is it symbol for Infinite? and the output is which type Bigdecimal or any other type?

Upvotes: 0

Views: 375

Answers (1)

akond
akond

Reputation: 16035

(class (*' 4535353535345345345 5675675675675675677 4564564646456645))

is clojure.lang.BigInt and Clojure prints it like this:

;; src/clj/clojure/core_print.clj
(defmethod print-method clojure.lang.BigInt [b, ^Writer w]
  (.write w (str b))
  (.write w "N"))

so the N is just a note to let you know what type of integer it realy is.

This does not mean, though, you have to put N in the end to let Clojure know what kind of integer it is.

Upvotes: 3

Related Questions