Jump to content
  • Advertisement
Sign in to follow this  
sarbruis

non-floating point 12-digit datatype?

This topic is 4594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm just looking for something that can store a 12-digit barcode. Long double stores enough digits, but when it's output it's in scientific notation. Do I need to make my own datatype? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Which programming language are you using, and what compiler? If this was VB I'd recommend giving the Currency type a try.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
I believe long long will just barely give you enough room. It should be 64 bits under MinGW.
Actually, 64-bits is enough for 19 decimal digits.

Share this post


Link to post
Share on other sites
Okay, I did that and I'll type in a 12-digit number like 849569346323 and I initially read it in as a string, so when I use atoi() to change it back to a long long, I get some weird 10-digit number like 1465340171. Is this a problem with atoi()? Should I use a different function to convert from std::string to long long?

Share this post


Link to post
Share on other sites
atoi() only works for ints; for long long, I believe you can use boost::lexical_cast or stringstreams to get proper values.

Share this post


Link to post
Share on other sites
Quote:
Original post by sarbruis
Okay, I did that and I'll type in a 12-digit number like 849569346323 and I initially read it in as a string, so when I use atoi() to change it back to a long long, I get some weird 10-digit number like 1465340171. Is this a problem with atoi()? Should I use a different function to convert from std::string to long long?
I think GCC implements an equivalent atoll() function for 64-bit integers.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!