Fibonacci Help

I maked this fibonacci program but when program print 92. number its going to print - numbers (for example 92. 121452536 93. -1242345245) why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
    intmax_t m=1;
    intmax_t n=0;
    int a=1;
    int i;
    cin >> i;
    while(a<=i)
    {
               m=m+n;
               cout << m << endl;
               Sleep(300);
               a++;
               if(a>i)
               {
               break;
               }
               n=m+n;
               cout << n << endl;
               Sleep(300);
               a++;
               }
               
    }
its probaby an int overflow if i understand you correctly, meaning it cant calculate a number higher than that. i use doubles and then it just converts it to scientific notation automatically
how i can use bigger numbers
a bigint class or double
3.54225e+020 is the same thing just in scientific notation
Topic archived. No new replies allowed.