non-floating point 12-digit datatype?
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.
Which programming language are you using, and what compiler? If this was VB I'd recommend giving the Currency type a try.
I believe long long will just barely give you enough room. It should be 64 bits under MinGW.
Quote:Original post by SiCraneActually, 64-bits is enough for 19 decimal digits.
I believe long long will just barely give you enough room. It should be 64 bits under MinGW.
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?
atoi() only works for ints; for long long, I believe you can use boost::lexical_cast or stringstreams to get proper values.
Quote:Original post by sarbruisI think GCC implements an equivalent atoll() function for 64-bit integers.
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement