This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                                7年前关闭。
            
                    
您能告诉我如何生成大于输入数的最小数,该输入数可以被8整除吗? (C语言中最好)

对于2的幂是否有一个通用的解决方案?

谢谢

最佳答案

大于或等于输入的最小数字,可被8整除:

return (input + 7) & ~7;


大于输入且可被8整除的最小数字:

return (input + 8) & ~7;

10-02 17:01