/*** * 保留2位小数 * @param floatValue * @return */ float scale(Float floatValue) { DecimalFormat format = new DecimalFormat("#.00"); String scaled = format.format(floatValue); return Float.parseFloat(sc
在编码过程中,我们通常碰到一组数据,需要自己简单的处理下,拿到数组中的总和,大小和平均值数据。 1.简单粗暴的方法,快速求和。 NSArray * array = @[@"35",@"786",@"111",@"73",@"80",@"58",@"34",@"3"]; float sum = [[array valueForK
最近遇到一个问题: 因为后台人员对于接口数据没有做空值处理。导致client接收到的有些数据为空(NSNull),而针对此类数据恰好client的存储结构为int和float类型。类型转换时报出了[NSNull intValue]或者[NSNull floatValue] unrecognized selector sent to instance 的
class MyClass{ private: static const int intvalue= 50; static const float floatvalue = 0.07f; }; 如上申请方式导致错误 error C2864: 'MyClass::floatvalue : only static const integral data members can be initialized within a class 1. 尝试使用 static