本文介绍了乘以时间轴和浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 嗨 如何在ojbective c中乘以时间串和浮点数。 例如timestring是2:00小时,浮点值是1.5。如何将这两个值相乘得到这样的答案3:00hous 提前谢谢。解决方案 将时间字符串转换为分钟作为浮点数:2 * 60 + 0 == 120.0 乘以原始浮点数:120.0 * 1.5 == 180.0 转换此到整数:180.0 == 180 取模数基数60(这是分钟):180%60 == 0 整数除以60(这个是小时):180/60 == 3 将两个值转换回字符串,记住分钟和冒号上的前导零。 HiHow to multiply timestring and float in ojbective c.for e.g. timestring is 2:00 hour and float value is 1.5. How to multiply these two values and get the answer like this 3:00housThanks in advance. 解决方案 Convert the time string to minutes as a float: 2 * 60 + 0 == 120.0Multiply by the original float: 120.0 * 1.5 == 180.0Convert this to an integer: 180.0 == 180Take the modulus base 60 (this is the minutes): 180 % 60 == 0Integer divide the value by 60 (this is the hours): 180 / 60 == 3Convert the two values back to a string, remembering the leading zeros on the minutes and the colon. 这篇关于乘以时间轴和浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 10:21