gpt4 book ai didi

ios:NSLog 显示十进制值

转载 作者:行者123 更新时间:2023-11-29 04:01:44 26 4
gpt4 key购买 nike

NSNumber *weekNum = [dictionary valueForKey:@"inSeasonFor"];
NSDecimalNumber *newWeekNum = ([weekNum intValue] *2)/4;
NSLog(@"%", [newWeekNum decimalValue]);

如何将 weekNum*2 除以 4 并保留十进制值并打印它?

最佳答案

您的意思是您也想要小数部分,对吧?

NSNumber *weekNum = [dictionary valueForKey:@"inSeasonFor"];
// multiplication by 2 followed by division by 4 is division by 2
NSLog(@"%f", [weekNum intValue] / 2.0f);

//我们也可以使用intfloat来解析。

关于ios:NSLog 显示十进制值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15774175/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com