如何在Java脚本中将值转换为双精度 [英] How to convert value to double in java script

查看:122
本文介绍了如何在Java脚本中将值转换为双精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Java脚本中将字符串值转换为double.有任何功能可以将其转换..请提出建议.

java脚本中也有任何函数可以检查该值是否为double,因为我们在c#中具有tryparse.double().
请就这两个问题提出建议,谢谢.

I need to convert a string value to double in java script. is there any function to convert that.. Please suggest.

Also is there any function in java script to check if the value is double or not as we have tryparse.double() in c#..

Please advise on these two issues, Thanks in advance.

推荐答案

这应该可以帮助您:JavaScript中的ParseFloat [ ^ ]
This should help you out: ParseFloat in Javascript[^]


我不知道javascript中是否有tryparse,但是如果您使用字符串,请说它的变量名是v,其值是"1,然后

var dble = v * 1.0;

将其转换.我怀疑v是否不是数字,dble变成NaN,但我猜在那里.
I don''t know of a tryparse in javascript, but if you take a string, say it''s variable name is v and it''s value is "1", then

var dble = v * 1.0;

will convert it. I suspect if v is not a number, dble becomes NaN, but I am guessing, there.


我认为它将为您提供帮助:
I think it will help you : parseFloat function in JavaScript^


这篇关于如何在Java脚本中将值转换为双精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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