Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        5年前关闭。
                                                                                            
                
        
用户输入这样的双精度值:2423242.6789。仅扫描2423242我该​​怎么办?

最佳答案

假设为正数,请使用floor()

#include <math.h>

double x;
scanf("%lf", &x);
x = floor(x);
// or
x = x < 0.0 ? ceil(x) : floor(x); // to cope with + and - doubles

关于c - 如何截断小数点后的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26091191/

10-09 20:44