Guest_imported
New member
- Jan 1, 1970
- 0
if i have a floating point number eg.
float number = 2001.08;
how can I round this number to one decimal place precison(eg. 2001.08 becomes 2001.5, or 2001.14 becomes 2001.1) and copy that decimal number(which is "one" in this case) to a variable called decimal_number using the sprintf() function?
int decimal_number = 1;
float numberB = 2001.1;
Apart from using sprintf(), are there any other ways to perform this conversion? I'm not sure how to write this in C.
Many thanks!
float number = 2001.08;
how can I round this number to one decimal place precison(eg. 2001.08 becomes 2001.5, or 2001.14 becomes 2001.1) and copy that decimal number(which is "one" in this case) to a variable called decimal_number using the sprintf() function?
int decimal_number = 1;
float numberB = 2001.1;
Apart from using sprintf(), are there any other ways to perform this conversion? I'm not sure how to write this in C.
Many thanks!