Arrays.asList() of an array

Let’s consider the following simplified example: public class Example { public static void main(String[] args) { int[] factors = {1, 2, 3}; ArrayList<Integer> f = new ArrayList(Arrays.asList(factors)); System.out.println(f); } } At the println line this prints something like “[[I@190d11]” which means that you have actually constructed an ArrayList that contains int arrays. Your IDE and … Read more

how to convert negative integer value to hex in python

Python’s integers can grow arbitrarily large. In order to compute the raw two’s-complement the way you want it, you would need to specify the desired bit width. Your example shows -199703103 in 64-bit two’s complement, but it just as well could have been 32-bit or 128-bit, resulting in a different number of 0xf‘s at the … Read more

Converting number in scientific notation to int

Behind the scenes a scientific number notation is always represented as a float internally. The reason is the varying number range as an integer only maps to a fixed value range, let’s say 2^32 values. The scientific representation is similar to the floating representation with significant and exponent. Further details you can lookup in https://en.wikipedia.org/wiki/Floating_point. … Read more

bitwise AND in Javascript with a 64 bit integer

Javascript represents all numbers as 64-bit double precision IEEE 754 floating point numbers (see the ECMAscript spec, section 8.5.) All positive integers up to 2^53 can be encoded precisely. Larger integers get their least significant bits clipped. This leaves the question of how can you even represent a 64-bit integer in Javascript — the native … Read more