WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
 
Forum
 

10^10 doesn't work!!!

xspider
Quote Post


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 rolleyes.gif

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
PMEmail Poster
Top
shoorick
Quote Post


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)
PMEmail PosterUsers Website
Top
xspider
Quote Post


Very Active Member
****

Group: Members
Posts: 64
Member No.: 10609
Joined: 27-July 08


so should i use something else except int dry.gif 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 blink.gif
PMEmail Poster
Top
dila
Quote Post


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
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

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