Sample Header Ad - 728x90

Rubbish value outputed by printf "%f" 380

1 vote
0 answers
56 views
The command
-sh
printf "%d, %f, %o, %s, %x, %X\n" 380 380 380 380 380 380
outputs
380, 20689...2384.000000, 574, 380, 17c, 17C
where the second output is a very large (with almost thousand digits) float. When I tried
-sh
printf "%f" 380
I got
-0.000000
I do not understand what's happening! When using %f together with other format specifiers it gives a very large float, while when using it alone, it outputs -0 (!), none of which is expected. Can someone explain the reason? For reference, I am on a Kali Linux WSL.
Asked by KeShAw (13 rep)
Jan 18, 2025, 07:32 PM
Last activity: Jan 21, 2025, 02:35 PM