How to Increase the Resolution of analogRead()! (from 10-bits up to 21-bits)

Grumpy_Mike:
Due to the faulty sample code I have not managed to test any resoloution higher than 16 bits. However as mentioned the resoloution of the floating point variable is going to affect things. Already in the sample code floating point constants are defined that exceed the resoloution of a floating point number. Note that in the arduino float and double are the same size.

Goodness, so many unverified accusations! I understand that floating point numbers don't always store what you input in the code, if you use too many decimal digits. If my "faulty sample code" really was exceeding the resolution of a floating point number, don't you think that the const float values I defined would be altered once stored?

Run this code:

//constants required to determine the voltage at the pin
const float MAX_READING_10_bit = 1023.0;
const float MAX_READING_11_bit = 2046.0;
const float MAX_READING_12_bit = 4092.0;
const float MAX_READING_13_bit = 8184.0;
const float MAX_READING_14_bit = 16368.0;
const float MAX_READING_15_bit = 32736.0;
const float MAX_READING_16_bit = 65472.0;
const float MAX_READING_17_bit = 130944.0;
const float MAX_READING_18_bit = 261888.0;
const float MAX_READING_19_bit = 523776.0;
const float MAX_READING_20_bit = 1047552.0;
const float MAX_READING_21_bit = 2095104.0;

void setup() 
{
  Serial.begin(115200);
  Serial.println(MAX_READING_10_bit,10);
  Serial.println(MAX_READING_11_bit,10);
  Serial.println(MAX_READING_12_bit,10);
  Serial.println(MAX_READING_13_bit,10);
  Serial.println(MAX_READING_14_bit,10);
  Serial.println(MAX_READING_15_bit,10);
  Serial.println(MAX_READING_16_bit,10);
  Serial.println(MAX_READING_17_bit,10);
  Serial.println(MAX_READING_18_bit,10);
  Serial.println(MAX_READING_19_bit,10);
  Serial.println(MAX_READING_20_bit,10);
  Serial.println(MAX_READING_21_bit,10);
  
  Serial.println("");
  
  Serial.println((unsigned long)MAX_READING_10_bit);
  Serial.println((unsigned long)MAX_READING_11_bit);
  Serial.println((unsigned long)MAX_READING_12_bit);
  Serial.println((unsigned long)MAX_READING_13_bit);
  Serial.println((unsigned long)MAX_READING_14_bit);
  Serial.println((unsigned long)MAX_READING_15_bit);
  Serial.println((unsigned long)MAX_READING_16_bit);
  Serial.println((unsigned long)MAX_READING_17_bit);
  Serial.println((unsigned long)MAX_READING_18_bit);
  Serial.println((unsigned long)MAX_READING_19_bit);
  Serial.println((unsigned long)MAX_READING_20_bit);
  Serial.println((unsigned long)MAX_READING_21_bit);
}

void loop(){}

I see no alterations. Here's my output; exactly what I input:

1023.0000000000
2046.0000000000
4092.0000000000
8184.0000000000
16368.0000000000
32736.0000000000
65472.0000000000
130944.0000000000
261888.0000000000
523776.0000000000
1047552.0000000000
2095104.0000000000

1023
2046
4092
8184
16368
32736
65472
130944
261888
523776
1047552
2095104

For more understanding of floats, you might try reading about how the exponent & mantissa are stored, according to the IEEE standard. Google "ieee float exponent mantissa" to start.