What is the best data type to use for currency

Posted on 2007-08-03
Last Modified: 2013-11-05
Hi guys,
What is the best data type to use for currency. I ask this because currently I am using 'Single' data type however it often gives me 15.4999999, etc. so I have to keep rounding that to 2 decimal places and formatting. That seems so inefficient, especially if there is significant amount of computation being done.

Any suggestions?

Question by:gem56
    LVL 18

    Expert Comment

    LVL 17

    Assisted Solution

    the documentation recommends to use the Decimal Type
    LVL 18

    Accepted Solution

    You can always use the Format function to curtail the numer of digits you want to see after the decimanl like this:
    Dim decNumber as Decimal
    decNumber = 15.4999999

    Author Comment

    Tanks for that guys.

    I considered using Decimal type but thought in light of its size (8 bytes) that Single was more efficient to use (4 bytes). I'll try Decimal type but it seems I can't get away from using Round and Format functions. It's OK for now but in future if I need to do more repetitive computation I may feel different.


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now