001 - Java Insanity
Estimated time to read: 2 minutes
Overview¶
This is just a list of things that I found during my time learning Java and its many idiosyncrasies
Why append 'f' to a float?¶
A float, unless appended with an 'f' is just an int. A float and an int both use 4 bytes
The same occurs with a long, you have to use 'L' to tell the compiler it is a long value, else it will just use an int.
Appending 'f' to a float tells the compiler to do some magic, see below...
How tf does a float only take 4 bytes when an int takes 4 bytes¶
ints only take whole numbers (4 bytes) - 1542
up to 32-bit integers doubles are basically two ints stored together (4 bytes + 4 bytes) 4193.123491
- up to 64 bit integers or 32-bit wholes and 32-bit decimals, ish.
floats are magic (See IEEE 754) - They use exponents of a whole number to store 32-bit fractional data in 4 bytes. Basically, they clever, they make decimals possible, we happy.
How to not breach standards between Java implementations¶
--
Real numbers, wtf?¶
Numbers include real and imaginary numbers
Numbers¶
Numbers include:
- Imaginary
- Real
- Rational
- Fractions
- Integers
- Whole numbers
- Natural numbers
- Irrational
Real Numbers¶
Real numbers are any number that you can think of, including decimal points and recurring numbers 95015.18501583381
Real numbers are split into rational and irrational groups.
Imaginary Numbers¶
I haven't got a clue
Real¶
Rational¶
Real Rational Numbers - Integer Split / Adult Timeline¶
Natural Numbers¶
Natural numbers are integers, but not 0. 1,2,3,4,5,6
Whole Numbers¶
Whole numbers are (whole) integers including 0. 0,1,2,3,4,5
Integers¶
Integers are whole numbers that can be positive or negative -3,-2,-1,0,1,2,3
Real Rational Numbers - Fractional Split / Child Timeline¶
Fractional numbers¶
Fractional numbers are basically any number, that isn't a whole although it could be, and that isn't an irrational number.
Irrational¶
Real Irrational Numbers¶
Irrational numbers are numbers that continue forever such as 3.333333333r and pi. Anything that has a recurring value is irrational.