Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6771875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:29:03+00:00 2026-05-26T15:29:03+00:00

I’m working on some small projects and don’t fully understand data types and their

  • 0

I’m working on some small projects and don’t fully understand data types and their uses. Here are some things I’m wrestling with.

What data type would I use to represent:

  • a person’s salary?
  • a person’s date of birth?
  • a person’s name?
  • a person’s Social Security Number?
  • the number of dependents a person is going to claim on their taxes?
  • the weight of the Earth?

Are there any rock solid resources for data types?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:29:04+00:00Added an answer on May 26, 2026 at 3:29 pm
    • Money (salary): Decimal.
    • Birthday: DateTime.
    • Name: String.
    • Social Security Number: String.
    • Weight of the earth: float or double.

    Explanation

    Money

    The Decimal value type is appropriate for financial calculations requiring large numbers of significant integral and fractional digits and no round-off errors. The Decimal type does not eliminate the need for rounding. Rather, it minimizes errors due to rounding. – MSDN

    It also can’t be an integer because you’ll need a decimal point ($59.9) and integers cannot have one, you’d have to convert it, e.g. with a cast which will always round it up for you: ((int)7.001) == 8 is true.

    You won’t use a string either. Text is just the wrong representation (quantifying money does not result in a list of characters, right?). And you’d also like to run some math, I’m sure, and you cannot do that with strings directly because it’s not numeric. E.g. 2 + 2 = 4. Try the same with strings: "2" + "2" = "22" (+ is overloaded: it adds for numerics and concatenates for strings).

    Edit: My opinion of this has changed!.

    Computers and floating points are notoriously complicated and even error-prone (if you do not know precisely what you’re doing). I suggest to not use them for money or anything precise & critical.

    I recommend to use an integer type that will not overflow (for arbitrary size use BigInteger) and use it to represent the lowest resolution you need. E.g. you’re likely to be okay with representing dollars as cents, so 150 is how you would represent 1.5. Away with rounding errors and scary IEEE standards! woohoo! plus computers are faster with integers so you would typically get better performance, especially if you can manage to use an int, i.e. you’re certain it will not overflow.

    Phone Numbers & Security Number

    Phone numbers and security numbers are called numbers, but really they’re just a string of digits, aren’t they? at least that seems the common perception. Well that already tells you: use a string.
    You’re also unlikely to use a phone number for mathematical operations? (although I do suppose summing up phone numbers would make one wild afternoon).

    Birthday

    DateTime is the standard .NET type for dates, I’m sure there’s no need to explain why, the name is self-explanatory.

    Name

    String for obvious reasons.

    Weight

    double or float are used to this kind of things.
    It depends on how much precision you want. Double gives you more, but the trade-off is that it takes more memory. It only makes a real difference when you have tons of them. My rule of thumb is to go with doubles unless I actually need to use a single/float. That being said, from my experience, almost every game that has something like that (a gravity force value, a weight, and such) is usually a float and rarely a double. Sometimes the domain will give you a different rule of thumb while you’re working in it.

    Differences between float & double: link & another link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.