473,414 Members | 1,911 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,414 software developers and data experts.

Difference between CDec and CDbl

Can anyone explain the difference between these two conversion
functions? Thanks

Sep 24 '06 #1
7 22201
One converts to Decimal, other to Double?
Can anyone explain the difference between these two conversion
functions? Thanks
--
Greetings,
Josip Medved
http://www.jmedved.com

Sep 24 '06 #2
"James" <ja**********@gmail.comschrieb:
Can anyone explain the difference between these two conversion
functions?
They convert to different types.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Sep 24 '06 #3
i meant the technical differences... what does one read that the other
cannot? Thanks.
Herfried K. Wagner [MVP] wrote:
"James" <ja**********@gmail.comschrieb:
Can anyone explain the difference between these two conversion
functions?

They convert to different types.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Sep 24 '06 #4
i meant the technical differences... what does one read that the other
cannot? Thanks.
Since both decimal as double are numeric types, I doubt that there is
any difference, as in from what they can convert, but there is big
difference in types to which they convert to.

--
Greetings,
Josip Medved
http://www.jmedved.com

Sep 24 '06 #5
In addition to the other comments:

CDec returns a Decimal value.

CDbl returns Double value.

As you may know TypeOf Decimal IsNot TypeOf Double. Decimal is a base 10
floating point number, while Double is a base 2 floating point number. They
have different precisions & ranges.

If you have Option Strict On (you do have Option Strict On don't you)
attempting to use CDbl and assign it to a Decimal will cause a compile
error. While attempting to use CDec and assign it to a Double will cause an
implicit conversion from Decimal to Double (read it will work, but you
really did CDbl(CDec(?)).

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"James" <ja**********@gmail.comwrote in message
news:11********************@i42g2000cwa.googlegrou ps.com...
Can anyone explain the difference between these two conversion
functions? Thanks
Sep 24 '06 #6
As you may know TypeOf Decimal IsNot TypeOf Double. Decimal is a base 10
floating point number, while Double is a base 2 floating point number. They
have different precisions & ranges.

Can you explain this a little more? I work well with examples and I
don't really understand what you're saying here. Thanks!

Sep 24 '06 #7
Binary floating point & .NET:
http://www.yoda.arachsys.com/csharp/floatingpoint.html

Decimal floating point in .NET:
http://www.yoda.arachsys.com/csharp/decimal.html

The short of it is a Decimal number can exactly represent base 10 (ergo
Decimal) numbers. Double (and Single) cannot exactly represent base 10
numbers, as they store the numbers as base 2.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"James" <ja**********@gmail.comwrote in message
news:11**********************@d34g2000cwd.googlegr oups.com...
>As you may know TypeOf Decimal IsNot TypeOf Double. Decimal is a base 10
floating point number, while Double is a base 2 floating point number.
They
have different precisions & ranges.


Can you explain this a little more? I work well with examples and I
don't really understand what you're saying here. Thanks!
Sep 25 '06 #8

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

Similar topics

6
by: djc | last post by:
I have a sql field (MSDE 2000) of type Decimal. When inserting a value into the field from an asp.net web form I am using the CDec() function. If I enter a 2.1 through a 2.4 a 2.00 is entered into...
2
by: Sam | last post by:
I using ASP 3.0 for some calculation and it is prompt error message where CDbl is not accept 0.00. How can I solve it? Please help. Error Message =============
3
by: Laphan | last post by:
Hi All I understand that all asp classic vars are variants and to always make sure that you are working with the type that you want it is best to use these built-in Cxx() functions, but I'm...
6
by: michele | last post by:
Hi, I have a problem with two function: IsNumber() and CDbl() because when I invoke it they throw an exception. The problem I think is International Settings, because NumberDecimalSeparator and...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
3
by: rishabhshrivastava | last post by:
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...
4
by: cj | last post by:
I thought, apparently incorrectly, CDec("") would result in 0D. Unless someone here can tell me something better it seems in reading my report file I'll have to say something like amount =...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
12
by: Petronius | last post by:
Hallo, does anyone have an idea how to implement difference lists in Javascript? Thanks allot in advance
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.