计算逻辑问题? [英] Calculate Logic problem ?

查看:65
本文介绍了计算逻辑问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我尝试编码计算逻辑

我宣布变量是双倍总数;



然后

价格= 123;

总计+ =(价格)+(价格* 7/100);



结果= 131.61



然后我尝试减少总数(我的意思是删除价值)



现在

总计= 131.61

价格= 123;



然后我编码

总计 - =(价格)+(价格* 7 / 100);



结果= 131.61



i试试看我的程序是cal = 131.61 - 131。 61

然后我制作一个文本框

textbox1.text =total;



结果= 1.36418654150816E -14

Hi i try coded Calculate Logic
I Announced varible is double total;

then
price = 123;
total += (price) + (price * 7 / 100);

Result = 131.61

then i try decrease total (i mean delete value)

now
total = 131.61
price = 123;

then i coded
total -= (price) + (price * 7 / 100);

Result = 131.61

i try see my program is cal = 131.61 - 131 .61
then i make a textbox
textbox1.text = ""total;

Result = 1.36418654150816E-14

推荐答案

Double很难表示完美的数字,如果你将它们重新定义为浮点数,你将得到零。除非你需要极高的精度,否则我会坚持使用花车。
Double's have a hard time representing perfect numbers, if you redefine them as floats, you will get zero. Unless you need extreme precision, I would stick with floats.


这篇关于计算逻辑问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆