Re: Using floating point

Originally Posted by
Jerson
Assuming you want a 0.1 deg resolution, I would do this (keep in mind the largest value that Temp can hold. Temp*1000 will define the limit of temperature going into the routine)
Temp = (Temp*1000)/Cook_Adjust (max input temp is now 65 since 65*1000 approximately fills the 16b integer)
You could also do this
Temp = (Temp*100) / (Cook_Adjust / 10) (max input temp is 650. However, cook_adjust should be multiples of 10 to impact the calculations)
Now, convert to F
Temp = Temp + (Temp << 3) ' mul by 9 x + 8*x = 9x
Temp = Temp / 5 ' div by 5
Temp = Temp + (32*10) ' add 32 with 1 decimal accounted for
and display it by splitting the value thus
Display Temp / 10, ".", Temp MOD 10
You need to specify your input range to make this technique practical for you.
Well then, that seems a LOT easier now that I've had time to look at it. I'm going to use longs so that my max temp will fit and do the * 1000.
Thanks for the help!
"I have noticed that even those who assert that everything is predestined and that
we can change nothing about it still look both ways before they cross the street"
-Stephen Hawking
Bookmarks