I'm reading a book about OPENGL ES development. I came across to this sentence.
A float in Java has 32 bits of precision, while a byte has 8 bits of precision. This might seem like an obvious point to make, but there are 4 bytes in every float.
What exactly does that mean? Is this important to know in Android game development?
What exactly does that mean?
1 Byte= 8 Bit
4 Byte= 32 Bit
1Bit can have 2 conditions 0 or 1
2Bits can have 2² conditions 00 , 01, 10 and 11
Ok, now it comes to the hard point
If your accuracy should be +/-0.5 *the maximum size* that your number can be is 2^23. Now you may ask yourself and what is if i got a number that is larger than this? Anything that is bigger than this is bigger than 0.5.
(Single-Precission /32 Bit)
Is this important to know in android game development?
It is important, that you understood the basic concept behind this in nearly any programming language.
Take a look at that simple program, if you understood the output, that is all you need to know, first of all
public class DoubleError
{
public static void main(String[] args)
{
double x = 1.1;
double y = 0.1;
System.out.println("X is: " + x);
System.out.println("Y is: " + y);
System.out.println("X+Y is: " + (x + y));
}
}
EDIT:
Oh, and to totally crash your head,
here some more points that you should know:
Half- Precision = 16 Bit
Single-Precision = 32 Bit
Double-Precision = 64 Bit
EDIT 2:
Oh, and if you want to understand anything, check out this: IEEE_754-2008