By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

How to convert ascii too.... int64, unsigned long..

P: n/a
Hi,

I have this number, 1.5283632704970307 in char*, and I need to convert
it to a double type in C++ that is capable of storing that number of
precisions.... I tried doing atof and storing it to a double type. it
came back with 6 digits precision only.

I also have this number, 1159964886109, in char*, and I need to convert
it to uint64... i did a atol, it converted it to a 2147483647, which
truncated 4 bytes for me...

Thank you in advance.

T

Oct 4 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
ye****@gmail.com schrieb:
Hi,

I have this number, 1.5283632704970307 in char*, and I need to convert
it to a double type in C++ that is capable of storing that number of
precisions.... I tried doing atof and storing it to a double type. it
came back with 6 digits precision only.

I also have this number, 1159964886109, in char*, and I need to convert
it to uint64... i did a atol, it converted it to a 2147483647, which
truncated 4 bytes for me...

Thank you in advance.

T
Try std::istringstream ...

Oct 4 '06 #2

P: n/a
ye****@gmail.com wrote:
I have this number, 1.5283632704970307 in char*, and I need to convert
it to a double type in C++ that is capable of storing that number of
precisions.... I tried doing atof and storing it to a double type. it
came back with 6 digits precision only.
How do you know? What did you do to find that out?
I also have this number, 1159964886109, in char*, and I need to
convert it to uint64... i did a atol, it converted it to a
2147483647, which truncated 4 bytes for me...
There is no 'uint64' in C++. It's most likely a language extension
provided by your compiler. You need to look in the compiler manual or
ask in the newsgroup dedicated to your compiler to find out what to
use to convert a string into 'uint64'. Perhaps a special format
specifier in 'sscanf' would help?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 4 '06 #3

P: n/a
ye****@gmail.com wrote:
Hi,

I have this number, 1.5283632704970307 in char*, and I need to convert
it to a double type in C++ that is capable of storing that number of
precisions.... I tried doing atof and storing it to a double type. it
came back with 6 digits precision only.
How did you determine that? Did you print out the double as in

std::cout << some_double << '\n';

Well, then you only see six digits of precision because that is the default
precision for output streams. Use std::setprecision() to make more digits
visible.
>
I also have this number, 1159964886109, in char*, and I need to convert
it to uint64... i did a atol, it converted it to a 2147483647, which
truncated 4 bytes for me...
There is no uint64 in standard C++ (as far as I know).
Best

Kai-Uwe Bux

Oct 4 '06 #4

P: n/a
tak
How did you determine that? Did you print out the double as in
>
std::cout << some_double << '\n';

Well, then you only see six digits of precision because that is the default
precision for output streams. Use std::setprecision() to make more digits
visible.
I see. Yes, thats what I did. when I do setprecision, i do get more
digits.

I also have this number, 1159964886109, in char*, and I need to convert
it to uint64... i did a atol, it converted it to a 2147483647, which
truncated 4 bytes for me...

There is no uint64 in standard C++ (as far as I know).
if that is the case, what datatype will hold that many digits in C++
(12 bytes). And what function do i use to convert char* to "that" type?

thanks,
T

Oct 4 '06 #5

P: n/a
tak wrote:
>[no uint64 in standard C++]

if that is the case, what datatype will hold that many digits in C++
(12 bytes).
'double' usually fits that requirement. It has 16 digits of precision.
And what function do i use to convert char* to "that"
type?
There are strtod, sscanf, istringstream. You pick.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 4 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.