VS 2019 Do You Use Decimal, Single, Or Double? - VBForums

  • Register
  • Help
  • Remember Me?
VBForums - Visual Basic and VB .NET Discussions and More!
  • Advanced Search
  • Home
  • VBForums
  • Visual Basic
  • Visual Basic .NET
  • VS 2019 Do you use Decimal, single, or double?
Results 1 to 8 of 8 Thread: Do you use Decimal, single, or double? share-icon
  • Thread Tools
    • Show Printable Version
  • Display
    • Linear Mode
    • Switch to Hybrid Mode
    • Switch to Threaded Mode
  1. Nov 15th, 2020, 10:10 AM #1 RipVoidWinkle
    • View Profile
    • View Forum Posts
    RipVoidWinkle is offline

    Thread Starter Hyperactive Member Join Date Aug 2014 Posts 313

    Do you use Decimal, single, or double?

    Let's say you know the value is always going to be smaller, like below 32,000 Do you use Decimal, single, or double? I almost prefer Decimal just for readability, for some weird reason.
    Reply With Quote Reply With Quote
  2. Nov 15th, 2020, 01:56 PM #2 passel
    • View Profile
    • View Forum Posts
    passel is offline Sinecure devotee Join Date Aug 2013 Location Southern Tier NY Posts 6,583

    Re: Do you use Decimal, single, or double?

    Is that 32 thousand, or 32 with three decimal digits. If the numbers don't require decimal places, I would generally use Integer (32-bit). If I don't need a lot of precision, say the altitude of an aircraft in meters, or the heading in degrees, then I would use Single. For something where I want more resolution, like Latitude or Longitiude, then I would use Double. Doubles and Singles are generally about the same speed in calculations, but if doing a lot of math functions, then I would use Doubles for that as well. Using Decimal is slower and bulkier than the other types, and I haven't had a need to use it as I don't usually do financial or data base storage that may prefer the Decimal type.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
    Reply With Quote Reply With Quote
  3. Nov 15th, 2020, 05:22 PM #3 David Anton
    • View Profile
    • View Forum Posts
    David Anton is offline Fanatic Member Join Date Jan 2006 Posts 710

    Re: Do you use Decimal, single, or double?

    Accuracy vs performance: https://docs.microsoft.com/en-us/dot...ric-data-types "The Double data type is faster and requires less memory, but it is subject to rounding errors. The Decimal data type retains complete accuracy to 28 decimal places." i.e., don't use double or single if you can't stomach any rounding errors.
    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com
    Reply With Quote Reply With Quote
  4. Nov 16th, 2020, 01:07 AM #4 digitalShaman
    • View Profile
    • View Forum Posts
    digitalShaman is offline Frenzied Member Join Date May 2014 Location Central Europe Posts 1,387

    Re: Do you use Decimal, single, or double?

    i usually use double. only in some cases where i know that a single precision is sufficient and memory might be an issue, i use singles. i almost never use decimal.
    Reply With Quote Reply With Quote
  5. Nov 18th, 2020, 11:38 AM #5 kebo
    • View Profile
    • View Forum Posts
    • Visit Homepage
    kebo is offline Still learning kebo's Avatar Join Date Apr 2004 Location Gardnerville,nv Posts 3,762

    Re: Do you use Decimal, single, or double?

    For integral numbers I use int or long depending on the size of the value. For fractional values, I use Single only if the method I'm passing to requires a Single type, otherwise I use Doubles exclusively unless I need to ensure exact precision, then I'll use a Decimal.
    Process control doesn't give you good quality, it gives you consistent quality. Good quality comes from consistently doing the right things. Vague general questions have vague general answers.A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided. ______________________________ Last edited by kebo : Now. Reason: superfluous typo's
    Reply With Quote Reply With Quote
  6. Nov 18th, 2020, 01:23 PM #6 dbasnett
    • View Profile
    • View Forum Posts
    • Visit Homepage
    dbasnett is offline Powered By Medtronic dbasnett's Avatar Join Date Dec 2007 Location Jefferson City, MO Posts 9,836

    Re: Do you use Decimal, single, or double?

    Assuming fractional values when dealing with finances(money) I use Decimal.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer << "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein
    Reply With Quote Reply With Quote
  7. Nov 18th, 2020, 11:37 PM #7 jmcilhinney
    • View Profile
    • View Forum Posts
    • Visit Homepage
    jmcilhinney is online now Super Moderator jmcilhinney's Avatar Join Date May 2005 Location Sydney, Australia Posts 110,862

    Re: Do you use Decimal, single, or double?

    Quote Originally Posted by kebo View Post For integral numbers I use int or long depending on the size of the value. For fractional values, I use Single only if the method I'm passing to requires a Single type, otherwise I use Doubles exclusively unless I need to ensure exact precision, then I'll use a Decimal. Indeed, Integer and Double should be the default for whole and real numbers respectively, because these are the types that modern CPUs handle most efficiently. That's the reason that numeric literals without a decimal point and with are implicitly those types respectively unless you explicitly force them to another type using a suffix. For whole numbers, use Long or BigInteger as required for values with a larger range and only use Short or Byte when you explicitly need to use the data as those types, e.g. the loop counter in a For loop should be type Integer, even for very small ranges, unless you explicitly need something else. For real numbers, use Single only in specific cases where it is required. Both Single and Double are susceptible to round-off errors so, in cases where that is an issue, use Decimal instead. It's not an issue as often as people think it is though. Producing a single value with a round-off error generally doesn't really matter in cases where you should only care about the first one or two decimal places anyway. It's only really if you need to do something like sum a lot of values that you need the accuracy that Decimal provides. The one other scenario where you should consider using Short or Single is when memory is a genuine issue, e.g. an embedded system. For the vast majority of PC and even phone applications, the tiny bit of memory you save is simply insignificant.
    Why is my data not saved to my database? | MSDN Data Walkthroughs VBForums Database Development FAQ My CodeBank Submissions: VB | C# My Blog: Data Among Multiple Forms (3 parts) Beginner Tutorials: VB | C# | SQL
    Reply With Quote Reply With Quote
  8. Nov 27th, 2020, 09:04 PM #8 Niya
    • View Profile
    • View Forum Posts
    Niya is offline Angel of Code Niya's Avatar Join Date Nov 2011 Posts 8,758

    Re: Do you use Decimal, single, or double?

    Short answer. Decimal for finance. Double for science.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena Copy/move files using Windows Shell | I'm not wanted C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter There's just no reason to use garbage like InputBox. - jmcilhinney The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber
    Reply With Quote Reply With Quote
Quick Navigation Visual Basic .NET Top
  • Site Areas
  • Settings
  • Private Messages
  • Subscriptions
  • Who's Online
  • Search Forums
  • Forums Home
  • Forums
  • Visual Basic
    1. Visual Basic .NET
      1. CodeBank - VB.net
    2. Visual Basic 6 and Earlier
      1. CodeBank - Visual Basic 6 and earlier
    3. TwinBASIC
      1. CodeBank - TwinBASIC
    4. Universal Windows Platform and Modern Windows Experience
    5. Xamarin
    6. Mobile Development
    7. ASP, VB Script
    8. Office Development
    9. Database Development
    10. Reporting
    11. API
    12. Games and Graphics Programming
      1. Game Demos
    13. COM and ActiveX
    14. Network Programming
    15. Visual Basic FAQs
    16. Slow Chat with the Microsoft Visual Basic team
  • .NET and More
    1. ASP.NET And ASP.NET Core
    2. Visual Basic .NET
    3. MVC .Net
    4. C#
    5. Microsoft Azure and Cloud Dev
    6. WPF, WCF, WF
    7. .NET Architecture and Design
    8. Silverlight
  • General
    1. General Developer Forum
    2. IoT, IoE, and Maker Forum
    3. Testers and Testing
    4. Application Testing
    5. Application Deployment
    6. Linux Development
    7. General PC
    8. VBForums Coding Contests
      1. Contest Entries
    9. Code It Better
    10. Maths Forum
  • Other Languages
    1. Other BASIC
    2. C and C++
    3. Java
    4. PHP
    5. XML, HTML, Javascript, Web and CSS
    6. jQuery
    7. Assembly
    8. Other Programming Languages
  • VBForums CodeBank
    1. CodeBank - Visual Basic .NET
    2. CodeBank - Visual Basic 6 and earlier
    3. CodeBank - ASP / ASP.NET / Blazor / MVC / Web API
    4. CodeBank - C#
    5. CodeBank - C++
    6. CodeBank - Java / J#
    7. CodeBank - PHP
    8. Codebank - Game Programming
    9. Codebank - Mobile Development
    10. CodeBank - JavaScript
    11. Codebank - Cascading Style Sheets (CSS)
    12. CodeBank - Other
  • VBForums UtilityBank
    1. UtilityBank - Utilities
    2. UtilityBank - IDE Add-Ins
    3. UtilityBank - Components
    4. UtilityBank - Tutorials
    5. UtilityBank - Other
  • Projects
    1. Project Requests
    2. Project Communication Area
  • Jobs
    1. Just VB Jobs
    2. Open Positions (Jobs)
    3. Looking for Work
  • Community
    1. Forum Feedback
    2. General Discussion / Chit Chat
      1. World Events
    3. Forum Test Area
« Previous Thread | Next Thread »
  • Home
  • VBForums
  • Visual Basic
  • Visual Basic .NET
  • VS 2019 Do you use Decimal, single, or double?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is On
  • HTML code is Off

Forum Rules

Click Here to Expand Forum to Full Width
Terms and Conditions | About Us | Privacy Notice | Contact Us | Advertise | Sitemap| California - Do Not Sell My Info

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.

All times are GMT -5. The time now is 06:35 AM.

Từ khóa » Visual Basic Double To Decimal