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

Diff between CSng and CDbl

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 confused about whether I should use CSng
or CDbl for my calcs.

I don't think they will ever be more than say 6 decimal places (at the very
most usually 2 or 3) and the value the other way won't be in the millions
(chance would be a fine thing!!) so should I be using CSng or CDbl?

Is there any kind of performance degradation in using one over the other?

Is there any kind of accuracy degradation in using one over the other?

Your comments would be appreciated.

Rgds Laphan
Nov 22 '05 #1
3 8467
Diff between single and double?

Size

See inline:
Laphan wrote:
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 confused about whether
I should use CSng or CDbl for my calcs.

I don't think they will ever be more than say 6 decimal places (at
the very most usually 2 or 3) and the value the other way won't be in
the millions (chance would be a fine thing!!) so should I be using
CSng or CDbl?
I would choose single.

Is there any kind of performance degradation in using one over the
other?
No, not that you would notice unless you were performing millions of loops
with it.

Is there any kind of accuracy degradation in using one over the other?


No
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Nov 22 '05 #2
Many thanks Bob

This has put my mind at ease.

Rgds Laphan

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Diff between single and double?

Size

See inline:
Laphan wrote:
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 confused about whether
I should use CSng or CDbl for my calcs.

I don't think they will ever be more than say 6 decimal places (at
the very most usually 2 or 3) and the value the other way won't be in
the millions (chance would be a fine thing!!) so should I be using
CSng or CDbl?
I would choose single.

Is there any kind of performance degradation in using one over the
other?
No, not that you would notice unless you were performing millions of loops
with it.

Is there any kind of accuracy degradation in using one over the other?


No
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Nov 22 '05 #3
Shouldn' t have any visible effect on performance unless you have very
numerous calculations. Check the VBScript doc for a description of the
Single and Double types :
http://msdn.microsoft.com/library/de...bsDataType.asp

Not sure but your post may lead to think that you have numerous conversions
in your code. You have to do this once so that the variable you are using
have then the proper subtype (especially true for example with user input
that is returned as text). You don't need to do that in each and every
calculation.

The point is that ALL variables are variants. Even CSng and CDbl returns a
variant variable with the proper subtype. So once this is done for the
variable used for following calculations, converting again and again is
useless.

Likely picky and off topic but wanted to clarify this if needed...

--
Patrice

"Laphan" <in**@SpamMeNot.com> a écrit dans le message de
news:OY*************@TK2MSFTNGP10.phx.gbl...
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 confused about whether I should use CSng
or CDbl for my calcs.

I don't think they will ever be more than say 6 decimal places (at the very most usually 2 or 3) and the value the other way won't be in the millions
(chance would be a fine thing!!) so should I be using CSng or CDbl?

Is there any kind of performance degradation in using one over the other?

Is there any kind of accuracy degradation in using one over the other?

Your comments would be appreciated.

Rgds Laphan

Nov 22 '05 #4

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

Similar topics

2
by: Charley | last post by:
I've got a diff file that I think is a patch for a bunch of file in a directory. How do I apply this file? I thought it was #patch myfile.diff But that does nothing. I must be missing...
9
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the...
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 =============
6
by: Igor Shevchenko | last post by:
Hi! Suppose I have "pg_dump -s" of two pg installs, one is "dev", another is "production". Their schemas don't differ too much, and I want to get a "diff -u"-like schema diff so I can quickly...
4
by: Andreas Kasparek | last post by:
Hola! I'm preparing my master thesis about a XML Merge Tool implementation and was wondering if there is any open standard for XML diff regarding topics like: - is a diff result computed on...
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...
7
by: James | last post by:
Can anyone explain the difference between these two conversion functions? Thanks
7
by: magix | last post by:
Dear Guru, If I want to compare time, what is the best approach to go ? Any good example ? DateDiff ( ) ? Pseudocode ======== submitdate = rs.fields("submissiondate") -submissiondate is a...
6
by: Aaron Gray | last post by:
Hi, I am working on an HTML WYSISYG Wiki and need to display a diff page like WikiPedia does if two people edit a file at the same time to give the second user the diff. Basically with additions...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.