473,385 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Convert to Double(cDbl) in JavaScript

Hello All,
How can I convert a value to Double in JavaScript??? In vbscript i
believe its done as

cDbl(Value)

I tried lots of way but getting a value of "NaN".

Any suggestions/ideas will be truely appreciated.

Thanks.

Aug 21 '06 #1
3 63002
ri****************@gmail.com writes:
How can I convert a value to Double in JavaScript???
Convert it to a number. All numbers in JavaScript are doubles.

If the value you convert from is a string representation, you
can use either Number(value) or parseFloat(value). The first
requires the value to be a syntactically correct number, whereas
the latter allows trailing garbage.
I tried lots of way but getting a value of "NaN".
Well, success. NaN is a value of the number type (contrary
to its name :). It probably means that the value does not
have the correct format.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Aug 21 '06 #2
ri****************@gmail.com wrote:
Hello All,
How can I convert a value to Double in JavaScript??? In
vbscript i believe its done as
Javascript's only numeric type is an IEEE double precision floating
point number, so if you convert any value into a number that number will
be a double.

The shortest conversion of a value into a number is with the unary plus
operator

var numericVal = (+otherValue);

The most self-documenting is to pass the value as an argument to the
Number object constructor called as a function:-

var numericVal = Number(otherValue);
cDbl(Value)

I tried lots of way but getting a value of "NaN".
That is a different issue, it implies that the value you are trying to
convert is Not a Number (NaN) when type converted into a number. That
may be that it is a string that is not in the correct form to be
converted into a number, or it is an object of some sort that does no
have a - valueOf - method that returns a number primitive or a value
that will type-convert into a number.

Without seeing the input value, and what you are doing with it, it will
not be possible to say.

Richard.
Aug 21 '06 #3
JRS: In article <11**********************@i42g2000cwa.googlegroups .com>
, dated Mon, 21 Aug 2006 15:32:56 remote, seen in
news:comp.lang.javascript, ri****************@gmail.com posted :
>How can I convert a value to Double in JavaScript??? In vbscript i
believe its done as

cDbl(Value)

I tried lots of way but getting a value of "NaN".

Any suggestions/ideas will be truely appreciated.
Before posting here you should have read the newsgroup and its FAQ,
frequently cited. All of it, but especially sections 2 & 4.21.

All numbers (except when stored as strings) are stored as IEEE Doubles.

To convert a numeric string to a number use unary +, parseInt,
parseFloat, or a purely arithmetic context.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Danny | last post by:
I am new to java/javascript. I wrote javascript to proces a cookie. I don't like that fact that the code is visible to all. Can I create a java application that resides on the server and call it...
4
by: D Newsham | last post by:
Hi, This javascript creates a table that has a header and side column that do not move while scrolling through the table. I need to convert this to vb script. Can anybody help, or do you have...
5
by: Robin Johnson | last post by:
Hi, I've written an engine in Javascript for running text adventure games on a web page: http://www.robinjohnson.f9.co.uk/adventure/hamlet.html (That's the only game I've written with it so...
1
by: sathyan8294 | last post by:
what is websites for convert javascript to vbscript?
7
by: maria80e | last post by:
Is it possible to convert javascript(.js) file as exe or dll? Regards, Maria prabudass E
7
by: deepthi230 | last post by:
how can i convert a javascript string to xml string?
2
by: David | last post by:
Hey can anyone help me convert a javascript array into a ruby array. Ive been struggling with this since friday to no avail. This is the function with the ajax.request call that is supposed to...
2
by: murugavelmsc | last post by:
Hi, i have a javascript code. I want to convert into VBscript. pls help me Javascript Code:
5
by: rmartine28 | last post by:
i am looking to post something in myspace profile that is java but their system doesn't allow java script, can any one tell me how to convert a java script into htlm ?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.