Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

Float printf printing
0
Posted

When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

0

14.2 I’m trying to take some square roots, and I’ve simplified the code down to main() { printf(“%f\n”, sqrt(144.)); } but I’m still getting crazy numbers. 14.3 I’m trying to do some simple trig, and I am #including , but the linker keeps complaining that functions like sin and cos are undefined. 14.4a My floating-point calculations are acting strangely and giving me different answers on different machines. 14.4b I’m sure I’ve got the trig functions declared correctly, but they’re still giving me wrong answers.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123