[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

BeeJ

5/26/2012 1:48:00 AM

Well really the question is why use currency vs use decimal (variant)?
Maybe this is a history lesson.

I use CDec when I want to use large numbers.
I also see many references in MSDN Oct to using CCur and LARGE INTEGER
type for things like Seek operation and others.

My large file I/O routine uses the Large Int Type for seeking.
So do other methods I have written.
Some APIs return high and low parts that need to be converted to a
single value. I have methods that do convert it to Decimal (variant)
or currency.

So is there any benefit to using one or the other when it is not a
pre-specified usage?

Why would I do math using currency when doing variant (decimal) works?

Typically I do <air code>

Dim vSum as variant

vSum = CDec(big1 + big2)

if this is a potential overflow then

vSum = CDec(big1 + CDec(big2))

or sometimes just initialize a variable

vSum = CDec(0)

then just use vSum as a decimal.

--
So where are we?
Not the street address.
Not the city.
Not the country.
Not the Earth.
Not the Solar System.
Not the Galaxy.
Not the Universe.
Not the Brane.
So where is the Brane?
Where are we?

Life is but a dream!


4 Answers

Evan Platt

12/16/2011 3:07:00 PM

0

On Thu, 15 Dec 2011 12:56:57 -0500, "WeReo_BoY" <invaild12345@aol.com>
wrote:

>And you-you shall never silence the legend of the Lifshine. The Legend of
>the Glory behooves you. The power of the Wereo contains you.

God and the Cancer will silence you, either that or the fact that you
stuff your fat piggy face, a heart attack will silence your fat ass.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.

Mike Williams

5/26/2012 8:57:00 AM

0

"BeeJ" <nospam@spamnot.com> wrote in message
news:jppcoc$hnp$1@speranza.aioe.org...

> Well really the question is why use currency vs use
> decimal (variant)? Maybe this is a history lesson.
> I use CDec when I want to use large numbers.
> I also see many references in MSDN Oct to using
> CCur and LARGE INTEGER type for things like
> Seek operation and others.

It all depends on what you are doing. The most obvious difference between
Currency and Decimal is that Currency is a data type in its own right
whereas Decimal can only be held in a Variant. Also, Currency is essentially
a large integer 8 bytes) which VB views as having a fixed four decimal
places whereas Decimal uses 12 bytes and it can have a variable number of
decimal places (from zero up to 28), so it can hold a much larger range of
numbers. Decimal of course, being essentially a large integer under the
hood, is much faster than Currency. In a standard compiled exe a simple
addition of the kind you outlined in your post would run about ten times
faster using Currency than it would using Decimal. As with most things, it's
horses for courses.

Mike



Larry Serflaten

5/27/2012 3:27:00 AM

0

Mike Williams wrote:
> Decimal of course, being essentially a large integer under the
> hood, is much faster than Currency. In a standard compiled exe a simple
> addition of the kind you outlined in your post would run about ten times
> faster using Currency than it would using Decimal. As with most things, it's
> horses for courses.

Oops - A bit of vice versa there at the start...

Speaking of vice versa; courses for horses are racetracks, right?

LFS

Mike Williams

5/27/2012 6:45:00 AM

0


"Larry Serflaten" <serflaten@gmail.com> wrote in message
news:5da13234-57f0-4967-9068-18ff975c177e@googlegroups.com...
> Mike Williams wrote:
>> Decimal of course, being essentially a large integer under the
>> hood, is much faster than Currency. In a standard compiled exe a simple
>> addition of the kind you outlined in your post would run about ten times
>> faster using Currency than it would using Decimal. As with most things,
>> it's
>> horses for courses.
>
> Oops - A bit of vice versa there at the start...

Oops indeed!

> Speaking of vice versa; courses for horses are racetracks, right?

They certainly are ;-)

Mike