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.
如何获得数字的整数长度?在这种情况下,我在 while 循环中使用它。那么,我怎样才能在浮动长度的同时得到一些东西呢?
使用sizeof():
sizeof()
float f = 123.0f; for (unsigned i = 0; i < sizeof(f); i++) { ... }
或者您的意思是变量中值的长度?
float f = 123.0f; for (float i = 0.0f; i < f; i += 1.0f) { ... }