Home
Forum
Downloads
Link To Us
Programming Tools
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Forum
Home
Forum
Computer Science
C/C++
10^10 doesn't work!!!
Track this topic
|
Email this topic
|
Print this topic
xspider
Very Active Member
Group: Members
Posts: 64
Member No.: 10609
Joined: 27-July 08
he all yeah i'm here x) i just don't know why 10^10 doesn't give me the right result
CODE
#include <stdio.h>
#include <math.h>
int main()
{
int x = 1,p1;
while ( x < 11 ) {
p1=pow(x,x);
printf( "%d^%d=%d\n", x,x,p1 );
x++;
}
getchar();
}
and also i wan't to do an addition to the results like that:
1^1+2^2+3^3+4^4+5^5+6^6+7^7+8^8+9^9+10^10=10405071317
Sponsored Links
shoorick
Extremely Active Member
Group: Admins
Posts: 2314
Member No.: 160
Joined: 22-June 04
it is possible 10^10 does not fit into int...
04 294 967 295 - max for 32 bit uint (signed int - twice less)
10 405 071 317 - your value
maybe, overflow error should rise in this case, but who knows why not 8)
xspider
Very Active Member
Group: Members
Posts: 64
Member No.: 10609
Joined: 27-July 08
so should i use something else except int
damn i liked it x) anyway i've used double with format #f and look what it gave me
CODE
1^1=1.000000
2^2=4.000000
3^3=27.000000
4^4=256.000000
5^5=3125.000000
6^6=46656.000000
7^7=823543.000000
8^8=16777216.000000
9^9=387420480.000000
10^10=10000000000.000000
you can see that i gave me what i wan't but the zero's are annoying
dila
New Member
Group: Members
Posts: 16
Member No.: 823
Joined: 3-December 04
Use "%.0f" instead of "%g" to hide the decimal places.
Also, you can use "%.3f" to display just 3 decimal places .etc
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
«
Next Oldest
|
C/C++
|
Next Newest
»
Close Topic Options
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
Forum Home
Search
Help
Announcements & Forum Rules
- Announcements, Forum Rules & Guidelines
WinAsm Studio
- General Discussions
- Suggestions/Bug Reports
- WinAsm Studio FAQ
- Multilingual User Interface
- Add-Ins
HiEditor
- General Discussions
- Suggestions/Bug Reports
Assembly Programming
- Main
- Newbies
- Projects - Source Code
- Custom Controls
- Snippets
Computer Science
- C/C++
- Internet
- Hardware & PC maintenance
General
- Online Degrees - Distance Learning
- The Heap
- Russian
Sponsors
Computer Science
Internet
C/C++
Hardware & PC maintenance
HiEditor
General Discussions
Suggestions/Bug Reports
WinAsm Studio
General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming
Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules
Announcements
General
Online Degrees - Distance Learning
The Heap
Russian