Using int vs Integer

the Integer class is provided so that values can be boxed/unboxed in a pure OO manner. use int where appropriate unless you specifically need to use it in an OO way; in which case Integer is appropriate. Java Int vs Integer However, very different things are going on under the covers here. An int is … Read more

Comparing float and double primitives in Java

Take a look at What every computer scientist should know about floating point numbers. Squeezing infinitely many real numbers into a finite number of bits requires an approximate representation…. — Edit to show what the above quote means — You shouldn’t ever compare floats or doubles for equality; because, you can’t really guarantee that the … Read more

Overriding Default Primitive Type Handling in Json.Net

Unfortunately the method JsonReader.SetToken(JsonToken, Object, Boolean) is no longer virtual. In more recent versions of Json.NET (10.0.1 or later), one must override JsonReader.Read() and do the necessary conversion there, then update the reader’s value with the desired value type. For instance, if you would prefer your JsonTextReader to return Int32 instead of Int64 whenever possible, … Read more

What does int.class mean

A primitive becoming an Object For primitives, there are Class objects available as constants named TYPE in the corresponding wrapper classes — i.e. int.class is changed to java.lang.Integer.TYPE . For other types, the compiler creates a private member variable in the class being compiled to hold the Class object, and generates code to initialize that … Read more

How many primitives does it take to build a LISP machine? Ten, seven or five?

Basic Predicates/F-functions McCarthy‘s Elementary S-functions and Predicates were: atom Which was necessary because car and cdr are defined for lists only, which means you cannot count on any sort of answer to indicate what was happening if you gave car an atom. eq For testing equality between atoms. car For returning the first half (address) … Read more