草庐IT

double-double-arithmetic

全部标签

ios - Collection View 流布局上的 estimatedItemSize 导致单元测试崩溃 - EXC_ARITHMETIC

我有一个UICollectionViewFlowLayout和一个estimatedItemSize集。当我运行我的应用程序时,一切正常,但在我的单元测试中,每次我点击collectionView:dequeueReusableCellWithReuseIdentifier:时,我都会遇到EXC_ARITHMETIC崩溃。我知道这是由于我的estimatedItemSize造成的,因为删除它可以修复崩溃。有人知道为什么会这样吗?谢谢 最佳答案 我对UICollectionViewFlowLayout和estimatedItemSiz

ios - 转换矩形 : toView: returns double size and twice the distance from the origin

我将ImageView传递给需要ImageView大小的初始化方法。然后调用convertRect:toView:-(id)initWithImageView:(UIImageView*)imageView{self=[superinit];if(self){CGRectimageViewFrame=[[imageViewsuperview]convertRect:imageView.frametoView:self.view];}}调用方式:MyViewController*viewController=[[MyViewControlleralloc]initWithImageVie

ios - 将 'NSNumber *__strong' 发送到不兼容类型 'CLLocationDegrees' 的参数(又名 'double' )

NSNumber*latitude=[NSNumbernumberWithDouble:[[cityDictionaryvalueForKeyPath:@"coordinates.latitude"]doubleValue]];NSNumber*longitude=[NSNumbernumberWithDouble:[[cityDictionaryvalueForKeyPath:@"coordinates.longitude"]doubleValue]];CLLocation*listingLocation=[[CLLocationalloc]initWithLatitude:lati

iphone - ios double 来自没有四舍五入的字符串

下面的代码四舍五入我的纬度字符串。我不想让它变圆。双纬度必须为41.04546。NSString*latitude=@"41.04546";doublelat=latitude.doubleValue;//itgives41.0455CLLocationCoordinate2Dcoordinat;coordinat.latitude=lat;对于不能四舍五入的精确坐标。 最佳答案 试试这条线..NSString*latitude=@"41.04546";doublelat=[latitudedoubleValue];NSLog(@"

objective-c - 使用不兼容类型 'double' 的表达式初始化 'id'

我正在尝试使用以下代码为double赋值:doubledistanceFormat=[self.runsArray[indexPath.row]valueForKey:@"runDistance"];但我不断收到以下错误:Initialising'double'withanexpressionofincompatibletype'id'但是,我知道这个值是双倍的!有办法做到这一点吗? 最佳答案 你能试试:doubledistanceFormat=[[self.runsArray[indexPath.row]valueForKey:@

java - 使用 tcp 从 java 发送 double 到 C#

我有一个JavaSocketServer,它向C#客户端发送double。服务器使用DataOutputStream.writeDouble()发送double,客户端使用BinaryReader.ReadDouble()读取double。当我发送dos.writeDouble(0.123456789);并从服务器刷新它时,客户端读取并输出3.1463026401691E+151这与我发送的不同。C#和Javadouble的编码是否各不相同? 最佳答案 在Java中,DataOutputStream.writeDouble()在发送

Swift:如何存储对 Double、Int 的引用

我想在Swift中存储对基本类型(Double,Int)的引用,这样我一个变量改变了,另一个也改变了。这是一个例子:classMyClass{varvalue:Double?}varmyValue=1.0varinstance=MyClass()instance.value=myValue//Iwantinstance.valuetochangeto2.0instance.value=3.0//=>IwantmyValuetochangeto3.0这可能吗? 最佳答案 你可以使用类持有者:classRef{varvalue:Tini

ios - 如何接受来自 UITextField 的 Double 输入,并将值赋给变量?

我在评论中提出了我的问题。前三行必须弱吗?以及如何让varwage和varhours等于文本框。@IBOutletvarwageIn:UITextField!//doesthisneedtobeweak@IBOutletvarhoursIn:UITextField!//doesthisneedtobeweak@IBOutletvarpayOut:UILabel!//doesthisneedtobeweak@IBActionfuncgoButt(sender:AnyObject){varwage:Double=//wageInvarhours:Double=//hoursInvarpre

swift - 仅在我的结构中扩展 Double

我希望能够通过到String的自定义转换来扩展Double,但我想将其限制在类/结构的实现中。对于extensionDouble{varcustomStringOutput:String{guardself>=0.0else{return"Invalid"}return"Mynumberis:\(self)"}}structMyStruct{varmyNumber:Double=100.0}letmyStruct=MyStruct()letdoubleFail=99.0print(myStruct.myNumber.customStringOutput)//"Mynumberis:10

objective-c - 一些for循环的问题 - - "Cannot subscript a value of type ' Double' with an index of type 'int' "errors

我在有索引的地方收到很多“无法使用‘int’类型的索引下标‘Double’类型的值”错误?阵列?像这样此代码取自Obj-C,并尽可能翻译成Swift,但我不熟悉某些语法。我清理了for循环,但一些Obj-C语法仍然存在。你能帮我清理/重构我的代码吗?importUIKitimportFoundationimportAVFoundationletminFramesForFilterToSettle=10enumCurrentState{casestatePausedcasestateSampling}classViewController:UIViewController,AVCaptu