473,795 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hi,

I have this number, 1.5283632704970 307 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 8597
ye****@gmail.co m schrieb:
Hi,

I have this number, 1.5283632704970 307 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::istringstr eam ...

Oct 4 '06 #2
ye****@gmail.co m wrote:
I have this number, 1.5283632704970 307 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.co m wrote:
Hi,

I have this number, 1.5283632704970 307 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::setprecisi on() 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::setprecisi on() 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
4348
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 needs to read an ASCII data file of inventory records and build an appropriate dynamic data structure using structs and pointers. 10112 MICROPROCESSOR 2100 2 B 000008.50 000012.50 10235 CHARACTER_PRINTER 4013 4 C 000995.00 001295.00 10450...
6
41196
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
7123
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 without strtol or s/printf function. Thanks, whatluo.
3
9332
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 = managedInt; Also it would be nice to know how to do this: System::UInt64 managedInt;
3
2259
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, char *IN_msg ); DLLEXPORT long F_BDO_CalculAXplusB(short int *IN_Tab_entree ,int IN_taille , double *OUT_Tab_sortie_freq , double *OUT_Tab_sortie, double IN_A,
43
8464
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 is not extremely convenient. -- NOUN:1. Money or property bequeathed to another by will. 2. Something handed down from an ancestor or a predecessor or from the past: a legacy of religious freedom. ETYMOLOGY: MidE legacie, office of a deputy,...
8
8437
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 = "aabbccdd"; where aa is the LSB and dd is the MSB.
4
2550
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 . Following is the code : try { string receivedPath = "c:\\NEW\\";
22
4765
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
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10217
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7544
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.