Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个像这样的花车23.248500。我可以单独获取23零件和零件吗?0.248500
23.248500
23
0.248500
谢谢
对于正数,您可以使用floor(f)函数来获取23和f - floor(f)获取0.248500部分。
floor(f)
f - floor(f)
(我链接了 C++ 参考,但 C 库中存在相同的函数)。
正确的功能是modf().
modf()
怎么样:
float f = 23.248500; int a = (int)f; float f_minus_a = f - a;