I would like to enter a string such as "111111111111.. ...11111111" (50
ones),and then convert it to a
number(11111111 1111.....111111 11),because I want to use that number to
do some additions.How can I do that?
The following is my trial,but I find that the "a" is always 0.
#include<stdio. h>
#include<stdlib .h>
int main()
{
char string1[50];
int a;
scanf("%s",stri ng1);
a= atoi("string1") ;
printf("%d",a);
return 0;
}
Oct 30 '08
18 1716
Martin Ambuhl <ma*****@earthl ink.netwrites:
Ben Bacarisse wrote:
>66******@qq.com writes:
>>I would like to enter a string such as "111111111111.. ...11111111" (50 ones),and then convert it to a number(111111 111111.....1111 1111),because I want to use that number to do some additions.How can I do that?
I would not try. Your system is unlikely to have any integer type that can hold the value so you have to do something else.
This is an ubwarranted claim. The number of implementations without a
64 bit integral type is becoming vanishingly small.
And 66650755 needs only 50 of them.
True, but I thought the 1s were an example and the number was
decimal. This seemed reasonable since the code tried to use atoi.
You've given the OP the base-2 solution so all the bases are now
covered!
--
Ben. 66******@qq.com wrote:
I would like to enter a string such as "111111111111.. ...11111111" (50
ones),and then convert it to a
number(11111111 1111.....111111 11),because I want to use that number to
do some additions.How can I do that?
Well, if that is a binary number, you can use strtoll(); if that is a
decimal, _probably_ you have to need the gmp library to make that.
See: http://gmplib.org/
Good luck!
Cong
Mark McIntyre wrote:
>
.... snip ...
>
What is the largest number you can hold in an int?
INT_MAX, as read from <limits.h>.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
CBFalconer <cb********@yah oo.comwrites:
Mark McIntyre wrote:
>>
... snip ...
>> What is the largest number you can hold in an int?
INT_MAX, as read from <limits.h>.
By snipping most of Mark's message, you give the impression that he's
not already perfectly well aware of that. His intent, I think was to
encourage the OP to think about these questions, not to solicit
answers to be posted here.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
In article <49************ ***@yahoo.com>,
CBFalconer <cb********@mai neline.netwrote :
>What is the largest number you can hold in an int?
>INT_MAX, as read from <limits.h>.
Your habit of responding to posts without any regard for context
is making you look like a poor AI program.
-- Richard
--
Please remember to mention me / in tapes you leave behind.
Keith Thompson wrote:
CBFalconer <cb********@yah oo.comwrites:
>Mark McIntyre wrote:
>>>
... snip ...
>>> What is the largest number you can hold in an int?
INT_MAX, as read from <limits.h>.
By snipping most of Mark's message, you give the impression that
he's not already perfectly well aware of that. His intent, I
think was to encourage the OP to think about these questions, not
to solicit answers to be posted here.
Not so. By snipping I reduced the question/answer to a minimum
that could impress a relatively newbie reader. Usenet is not a
home for private messages. Everything is public.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
CBFalconer <cb********@yah oo.comwrites:
Keith Thompson wrote:
>CBFalconer <cb********@yah oo.comwrites:
>>Mark McIntyre wrote:
... snip ...
What is the largest number you can hold in an int?
INT_MAX, as read from <limits.h>.
By snipping most of Mark's message, you give the impression that he's not already perfectly well aware of that. His intent, I think was to encourage the OP to think about these questions, not to solicit answers to be posted here.
Not so. By snipping I reduced the question/answer to a minimum
that could impress a relatively newbie reader.
I don't understand. Whom are you trying to impress? And what does
that have to do with the original poster's question (which isn't
quoted here, but was quoted in the article to which you replied)?
Usenet is not a
home for private messages. Everything is public.
Certainly, but answers to questions are typically addressed to the
questioner, with others able to read the answer so that they can
either learn from it, correct it, or add to it. In this case, the
questioner was the original poster; Mark, quite reasonably, answered
by posing questions intended to lead the OP to figure things out for
himself.
If you happen to be walking by a classroom when the teacher is asking
the students "What is two plus three?", do you stick your head in the
door and shout "five"?
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
In article <ln************ @nuthaus.mib.or g>,
Keith Thompson <ks***@mib.orgw rote:
....
>If you happen to be walking by a classroom when the teacher is asking the students "What is two plus three?", do you stick your head in the door and shout "five"?
Actually, CBF probably would.
Keith Thompson wrote:
CBFalconer <cb********@yah oo.comwrites:
.... snip ...
>
>Not so. By snipping I reduced the question/answer to a minimum that could impress a relatively newbie reader.
I don't understand. Whom are you trying to impress? And what does
that have to do with the original poster's question (which isn't
quoted here, but was quoted in the article to which you replied)?
"Marks identity" and "Marks message" have little to do with it. I
usually don't check the writers identity. As I recall I simply
cleared up a point that appeared obscure, to say the least, in the
original.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from software giant such as Microsoft SQL
Server, Oracle, and Sybase?
Is PostgreSQL reliable enough to be used for high-end commercial
application? Thanks
|
by: Jack |
last post by:
On the 1st of January 1998, Bjarne Stroustrup gave an interview to the
IEEE's 'Computer' magazine. Naturally, the editors thought he would be
giving a retrospective view of seven years of object-oriented design,
using the language he created.
By the end of the interview, the interviewer got more than he had
bargained for and, subsequently, the editor decided to suppress its
contents, 'for the good of the industry' but, as with many of...
|
by: Olav.NET |
last post by:
I am a .NET/C++ developer who is supposed to do some work with Access.
I do not know much about it except for the DB part.
Questions:
*1*
I am looking for INTENSIVE books to get quickly up to speed.
I like books with practical exercises, and also with test questions (like
cert books)
*2*
|
by: agentxx04 |
last post by:
Hi. Our assignment was to creat a program that can find the average, median
& mode of a #of integers. Here's my program:
#include<stdio.h>
int main()
{
int item;
int a, b, t, mode;
int median_index;
|
by: Joseph S. |
last post by:
hi all,
debugging PHP applications interactively is possible, easy and free. I
am talking about PHPEclipse and using it for debugging over several
scripts or debugging through a session. Since I have wasted a lot of
time writing echo statements all over the code in order to confirm
program flow and watch variables, I feel I must share this with others
who will be facing similar problems.
PHPEclispe users can go to Step 5 directly....
| |
by: Donkey |
last post by:
Hello, I want to find out how many digits does each date type have and
how many bytes does it occupy in memory, so I wrote a program below:
#include <stdio.h>
const long double num=1123222.232121342;
main()
{
Printf("the number occupies: %i, and it is 1123222.232121342
\n",sizeof num);
printf("char: %i ,the number is %c\n",sizeof(char),(char)num);
|
by: TheRomance |
last post by:
i have a problem about insert integer to link list.
sorry it's too long but i try many times, many ways , it's still have an error
function is fix . can't change anything about function. i can only make a code that work with function.
Number.cpp
#include "Number.h"
|
by: Steven T. Hatton |
last post by:
No, this is not a troll, and I am not promoting Java, C-flat, D, APL, Bash,
Mathematica, SML, or LISP. A college teacher recently posted to this
newsgroup regarding her observation that there has been a significant
decline in the number of students opting to take courses in C++. I just
want to let people know what I believe are the biggest obstacles to C++
language acquisition, and what aspects of the language make it less
appealing than...
|
by: Amy Lee |
last post by:
Hello,
I major maths in mu university, and I wanna build an app to do
Steffensen's Acceleration Method. Here's my code:
/* Equation: x^3-x-1=0 */
#include <stdio.h>
#include <math.h>
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |