We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi every body I don't know why I don't have the float part of the temp var.
float temp; int H_Value; int L_Value; int value = 55; temp = value / 10; H_Value = (int)temp; L_Value = (int)(temp - H_value)*10;
Or, to be more precise: temp = value / 10; is an integer (value) divided by an integer literal ("10"), which results in a integer (5). That integer is then assigned to temp, and converted to a float representation (5.0) in the process. You want to do the division in floating point. So, try something like: temp = (float)value / 10; or temp = value / 10.0; to have the expression on the right hand side evaluate as a float. It occurs to me that you actually want the division to truncate for H_value. You could leave out "temp" entirely: H_value = value / 10; L_value = (value % 10) * 10; This code has no floating point at all, which will do nice things for speed and space requirements. (I'm not entirely sure you really want that last "* 10". If you're trying to separate the number into multiples of ten, and the leftover part, then it should just be L_value = value % 10, and your original code should have been L_value = temp - H_value * 10; ) Hmmm: Jon asked a few weeks back how often people actually needed both quotient and remainder from a single divison. Here's yet another case.
Thank you very much Kobi