dongmuyan5638 2012-03-07 01:56
浏览 6
已采纳

从输出的数字中扣除%并显示新的数字

How can I deduct a certain percentage from the outputted number and display a newly calculated number?

This is what I mean:

Original number is outputted by

<?= $number['originalnumber'] ?>

which on a user's display shows up as, let's say, number 199.

I want to deduct 3% from number 199, which results in 193.03 and display this new value instead of 199.

Basically calculating on the fly and outputting a new value, so the user never sees number 199 but only a new number 193.03

Mathematic formula is 199 - 199 * .03 = 193.03

So it would be something like this probably

<?= $number['originalnumber'] ?> - ( <?= $number['originalnumber'] ?> * 0.3 ) = display new value on user's screen.

I'm not exactly a programmer and have no idea how to do it, so the good line of code would be appreciated.

  • 写回答

3条回答 默认 最新

  • dongwo5449 2012-03-07 01:58
    关注
    199 - 199 * .03 = 193.03
    

    is

    199 * 0.97 = 193.03
    

    So

    <?= $number['originalnumber'] * .97 ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 35114 SVAC视频验签的问题
  • ¥15 impedancepy
  • ¥15 在虚拟机环境下完成以下,要求截图!
  • ¥15 求往届大挑得奖作品(ppt…)
  • ¥15 如何在vue.config.js中读取到public文件夹下window.APP_CONFIG.API_BASE_URL的值
  • ¥50 浦育平台scratch图形化编程
  • ¥20 求这个的原理图 只要原理图
  • ¥15 vue2项目中,如何配置环境,可以在打完包之后修改请求的服务器地址
  • ¥20 微信的店铺小程序如何修改背景图
  • ¥15 UE5.1局部变量对蓝图不可见