152.32元人民币,计算出100元1张,50元1张,2元2张,现在问题是我计算不出来角3张分2个。请问双精度在小数部分怎样计算,怎么去转成3张角和2个分?
代码如下:
double x,y,z,m,n,f,q;
x =(int)double.Parse(textBox1.Text)/100;
textBox2.Text =x.ToString();
y = x;
x =(int)(double.Parse(textBox1.Text)- (100 * y))/50;
textBox3.Text = x.ToString();
z = x;
x = (int)(double.Parse(textBox1.Text) - (100 * y) - (50 * z)) / 20;
textBox4.Text = x.ToString();
m = x;
x = (int)(double.Parse(textBox1.Text) - (100 * y) - (50 * z) - (20 * m)) / 10;
textBox5.Text = x.ToString();
n = x;
x = (int)(double.Parse(textBox1.Text) - (100 * y) - (50 * z) - (20 * m) - (10 * n)) / 5;
textBox6.Text=x.ToString();
f = x;
x =(int)(double.Parse(textBox1.Text) - (100 * y) - (50 * z) - (20 * m) - (10 * n) -(5*f))/1;
textBox7.Text=x.ToString();
q=x;
//下面计数到角就不会了
x =(double.Parse(textBox1.Text) - (100 * y) - (50 * z) - (20 * m) - (10 * n) - (5* f) - (1 * q))/0.1 ;
textBox8.Text =x.ToString();