如何获取变量的输出作为浮点值 [英] how to get output of a variable as float value

查看:190
本文介绍了如何获取变量的输出作为浮点值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im有以下问题..
想要获得浮动结果

i m having the follwing problem.. want to get the result in float

假设

int a= convert.toint32(textbox1.text);
int b= convert.toint32(textbox2.text);

float ans= math.sqrt(a*b);
label1.text= ans.tostring();

输出..

a=7
b=3

ans应为= 4.582
但是我得到一个错误

ans should be= 4.582 but i get an error

不能隐式转换类型'double'到'float'。

cannot implicitly convert type 'double' to 'float'.

pls help..how如何获取浮点数...

pls help..how can i get the float ans...

推荐答案

将您的代码更改为

double ans = math.sqrt(a*b);

这篇关于如何获取变量的输出作为浮点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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