- VBForums
- Visual Basic
- Visual Basic .NET
- VS 2019 Do you use Decimal, single, or double?
- If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
Results 1 to 8 of 8 Thread: Do you use Decimal, single, or double? - Nov 15th, 2020, 10:10 AM #1 RipVoidWinkle
- View Profile
- View Forum Posts
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 - Nov 15th, 2020, 01:56 PM #2 passel
- View Profile
- View Forum Posts
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 - Nov 15th, 2020, 05:22 PM #3 David Anton
- View Profile
- View Forum Posts
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 - Nov 16th, 2020, 01:07 AM #4 digitalShaman
- View Profile
- View Forum Posts
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 - Nov 18th, 2020, 11:38 AM #5 kebo
- View Profile
- View Forum Posts
- Visit Homepage
Still learning 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 - Nov 18th, 2020, 01:23 PM #6 dbasnett
- View Profile
- View Forum Posts
- Visit Homepage
Powered By Medtronic 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 - Nov 18th, 2020, 11:37 PM #7 jmcilhinney
- View Profile
- View Forum Posts
- Visit Homepage
Super Moderator Join Date May 2005 Location Sydney, Australia Posts 110,862 Re: Do you use Decimal, single, or double? Originally Posted by kebo 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 - Nov 27th, 2020, 09:04 PM #8 Niya
- View Profile
- View Forum Posts
Angel of Code 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 Quick Navigation Visual Basic .NET Top - Site Areas
- Settings
- Private Messages
- Subscriptions
- Who's Online
- Search Forums
- Forums Home
- Forums
- Visual Basic
- Visual Basic .NET
- CodeBank - VB.net
- Visual Basic 6 and Earlier
- CodeBank - Visual Basic 6 and earlier
- TwinBASIC
- CodeBank - TwinBASIC
- Universal Windows Platform and Modern Windows Experience
- Xamarin
- Mobile Development
- ASP, VB Script
- Office Development
- Database Development
- Reporting
- API
- Games and Graphics Programming
- Game Demos
- COM and ActiveX
- Network Programming
- Visual Basic FAQs
- Slow Chat with the Microsoft Visual Basic team
- .NET and More
- ASP.NET And ASP.NET Core
- Visual Basic .NET
- MVC .Net
- C#
- Microsoft Azure and Cloud Dev
- WPF, WCF, WF
- .NET Architecture and Design
- Silverlight
- General
- General Developer Forum
- IoT, IoE, and Maker Forum
- Testers and Testing
- Application Testing
- Application Deployment
- Linux Development
- General PC
- VBForums Coding Contests
- Contest Entries
- Code It Better
- Maths Forum
- Other Languages
- Other BASIC
- C and C++
- Java
- PHP
- XML, HTML, Javascript, Web and CSS
- jQuery
- Assembly
- Other Programming Languages
- VBForums CodeBank
- CodeBank - Visual Basic .NET
- CodeBank - Visual Basic 6 and earlier
- CodeBank - ASP / ASP.NET / Blazor / MVC / Web API
- CodeBank - C#
- CodeBank - C++
- CodeBank - Java / J#
- CodeBank - PHP
- Codebank - Game Programming
- Codebank - Mobile Development
- CodeBank - JavaScript
- Codebank - Cascading Style Sheets (CSS)
- CodeBank - Other
- VBForums UtilityBank
- UtilityBank - Utilities
- UtilityBank - IDE Add-Ins
- UtilityBank - Components
- UtilityBank - Tutorials
- UtilityBank - Other
- Projects
- Project Requests
- Project Communication Area
- Jobs
- Just VB Jobs
- Open Positions (Jobs)
- Looking for Work
- Community
- Forum Feedback
- General Discussion / Chit Chat
- World Events
- Forum Test Area
« Previous Thread | Next Thread » - 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 |