Oh I really do wish computers could add

Oh I really do wish computers could add, and multiply, and …

   float H = 1.00794;
   float S = 32.065;

   float H2S = (2*H + S);

If you believe:

  • the variable H2S has a value of 34.08088, then you don’t understand the problem
  • that my issue is around how the number is formatted when displayed, rather than an internal representation of how the number is stored, you don’t understand the problem
  • 1f and 1.0f have the same value and are the same number, you don’t understand the problem

If you appreciate that when 1f, 1.0f and 1.1f are assigned to different variables, and then displayed, the values displayed should be  1, 1.0 and 1.1, and not 1, 1, and 1.1, then you likely understand the issue. I am not aware of any programming languages that support Significant Figures within a native datatype. A programming language that natively supported Significant Figures per arithmetic operation and variable would make my life a lot easier. I don’t think these programming languages exist.

 
   float X = 1.00794f;
   X = 6.1f;

And yes I do appreciate that the metadata payload to accommodate for the change in significant figures in the variable reassignment of X above would have to be supported by the datatype. This is what I want.

And yes I also appreciate that the multiplicand below (this is in-part the same code excerpt copied from above)

   float H2S = (2*H + S);

has just one significant figure too. This is clearly a problem in the arithmetic. Actually the whole thing is a damn problem, and if you don’t see this as a problem, there’s another problem.

— Published by Mike, 14:43:58 16 September 2016

Leave a Reply