- 2
Set the value of double variable always with 3 digits decimal dot
Hi everyone In my code , user can input some numbers like : 2 7.2 8.444 9.728288 I want to set the values like this : 2.000 7.200 8.444 9.728 I want to set the value of double variables like that , not just print them . Because I want to work with them . Line Subtracting , multipluing and so on . In another words I don't want to assign these values to string variable . Because I can't work with them Thanks
3 Respuestas
- 1
visph
It is not my answer . But i have gotten idea from that .
First i calculate with my numbers
when my work was complete , then I set the value to 3 digit . so the result value that printed , converted to String
+ 1
printf("%.3f",num);
0
♨ Soumik 🎶
It is not true .
If the d variable was 6.1 , returns 6.1 .
Or if the d variable was 2 , returns 2.0 .
But I want to print 6.100 and 2.000 .
The answer is my description in answer 2
Thanks you ...