These r/ir_ac/dc_float these all 4 values is upto 2 decimal places and thats acceptable.
But, I want r_ratio and ir_ratio to be having more decimal places than just 2. Also I want R to be more decimal places. because it affects my next final answer
Edit : I dont have to print this R value, I think I can use that Serial.println(R,6); or something like that,I need to calculate it and the nuse it in further calculations
I can tell you as a mathematician and coder for over 40 years, on these 8 bit computers that if you desire higher precision, DON'T USE FLOATS.
Arduino has 64-bit type long long and type unsigned long long variables with 19 places precision. Arduino floats will give you six place mantissa and an exponent and the dirt in sand IEEE floating point technique... look that up for how and why, I just avoid floats.
float x = 10 / 11;
Serial.println(x,5);
float y = x/3;
Serial.println (y,6);
the dixision of x for y , it will use upto 2 decimal places of x only not 6. I agree that you can display that result (y) into 6 digits, but actually the division is done the output will be :
0.909090
0.300000
because 0.90/3 = 0.30 it doesn't take all digits of x for division
If I want 3 places precision on volts my working unit would be microvolts, giving me 6 places where I can lose 3 and still have volts.millivolts to display.
You have realise too , that a lot of decimal places doesn’t mean accuracy to that level .
If you are dividing 10/11 then the answer to 6 decimal places is not accurate as the numbers in the sum are to zero decimal places
Ie it’s not 10.00001/11.00001. Or even 10/11.3
Put some numbers in a calculator and see the effect of precision in that 10 and 11and see the effect in the answer .
What kind of variables are you working with? Where do the numbers come from? Are they measurements? To what level of precision are your measurements?
Floats are fine, as long as you don't need more than 6 or 7 correct digits. And, if your numbers represent measurements, probably everything after 6 digits is garbage anyway.
When I was fixing/writing accounting code in the 80's, every cent mattered.
My electric billing code got checked out by a watchdog agency (Herb Dennenberg's) over being 1 cent different from the electric company's --- turns out they were wrong and the whole issue of putting my client out of business went POOF and PECO likely never changed a thing in their method.
float x = 10.0 / 11.0;
Serial.println(x, 5);
float y = x / 3;
Serial.println (y, 6);
0.90909
0.303030
I do not see the problem you are claiming to have.
Note that float has 6 to 7 digits precision - not decimal places. If you have a number in the millions then the precision is taken up by the whole number part and no decimal digits are significiant.
One of the reasons IBM tended to use binary coded decimal on their computers, accountants get very nervous when told there is no way to exactly represent 10 cents are $0.10 when using binary.