473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
5 8561
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: - Steve - | last post by:
I've been given a school assignment and while everything else is easy there's one topic I'm completley lost on. I've been given an ASCII file that looks like this. During start-up, the program...
6
by: ESOJAY | last post by:
Is "typedef long long int64" the best way to define an int64 type in c? Are there better alternatives? Thanks, ESOJAY -- ESOJAY
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
3
by: Mike Miller | last post by:
What is the best way to convert a managed unsigned int64 to an unsigned long? Basically I need to do the following: System::UInt64 managedInt = 10; unsigned long unmanagedInt; unmanagedInt =...
3
by: Eric BOUXIROT | last post by:
hi, i must convert all of these eVC++ prototypes to use with VB.NET.... DLLEXPORT long F_BDO_MessageBoxOK(char *IN_title, char *IN_msg ); DLLEXPORT long F_BDO_MessageBoxOUINON(char *IN_title,...
43
by: Steven T. Hatton | last post by:
http://public.research.att.com/~bs/bs_faq2.html#int-to-string Is there no C library function that will take an int and convert it to its ascii representation? The example Bjarne shows in his faq...
8
by: Polaris431 | last post by:
I have a buffer that holds characters. Four characters in a row represent an unsigned 32 bit value. I want to convert these characters to a 32 bit value. For example: char buffer; buffer =...
4
by: krishp | last post by:
Hi, I need to convert raw data recieved from a device through C#.Net socket to BMP format. For some reason the image conversion is not happening proparly and I can see only blur image . ...
22
by: Peerless | last post by:
Hi, For some reason the below code doesnt produce results as i expect. #include<stdio.h> int main() { int hi=0xff; int low=0xee;
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.