Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
鉴于 1 磅 = 16 盎司,您基本上只需将其乘以 16:
$pounds = 8; $ounces = $pounds * 16; echo $ounces; // 128
...但是,如果磅是浮点数,您可能需要对其进行四舍五入。由于您正在谈论运输重量,因此您可能需要四舍五入:
$pounds = 8.536; $ounces = ceil($pounds * 16); echo $ounces; // 137
您可以将其放入函数中,如下所示:
function pounds_to_ounces ($pounds) { return ceil($pounds * 16); } echo pounds_to_ounces(8); // 128 echo pounds_to_ounces(8.536); // 137
Given that 1 pound = 16 ounces, you can basically just multiply it by 16:
...but, if pounds is a float, you will probably want to round it. Since you are talking about shipping weights, you probably want to round up:
You could put this into a function, like this:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
鉴于 1 磅 = 16 盎司,您基本上只需将其乘以 16:
...但是,如果磅是浮点数,您可能需要对其进行四舍五入。由于您正在谈论运输重量,因此您可能需要四舍五入:
您可以将其放入函数中,如下所示:
Given that 1 pound = 16 ounces, you can basically just multiply it by 16:
...but, if pounds is a float, you will probably want to round it. Since you are talking about shipping weights, you probably want to round up:
You could put this into a function, like this: