+ 2

Please see this code! When i user input 10 or 20 the code works smoothly when user input 30 the milliseconds goes into - value?

https://code.sololearn.com/c9h35AeBsxE8/?ref=app

21st Jan 2022, 6:17 AM
Lakshay Kamat
Lakshay Kamat - avatar
10 Réponses
+ 1
https://code.sololearn.com/c9FcO2jigQ5Z/?ref=app
21st Jan 2022, 8:14 AM
Aboubakar
Aboubakar - avatar
+ 4
The int values in c are contained in this interval [-2,147,483,648 to 2,147,483,647] that mean (-2exp(-16) to 2exp(16)-1) When the users put 30 The millisecond number will be greater than 2exp(16)-1 .so this value reach the negative value of int.you can imagine it like a circle :when you reach max positive value of int the next number will be the min value of int ,which mean hier negative value
21st Jan 2022, 7:26 AM
Aboubakar
Aboubakar - avatar
+ 1
Aboubakar how can i stop this please tell me
21st Jan 2022, 7:47 AM
Lakshay Kamat
Lakshay Kamat - avatar
+ 1
You can use the Type long int
21st Jan 2022, 7:52 AM
Aboubakar
Aboubakar - avatar
+ 1
Instead of using Type int for milisecond and the others Just use :long long int For example long long int milisecond;
21st Jan 2022, 7:55 AM
Aboubakar
Aboubakar - avatar
+ 1
And with long long int var exemple In printf("%lld",var);
21st Jan 2022, 8:00 AM
Aboubakar
Aboubakar - avatar
+ 1
Aboubakar Not working at all
21st Jan 2022, 8:14 AM
Lakshay Kamat
Lakshay Kamat - avatar
+ 1
Aboubakar thanks 😊 bro
21st Jan 2022, 8:18 AM
Lakshay Kamat
Lakshay Kamat - avatar
+ 1
Welcome
21st Jan 2022, 8:31 AM
Aboubakar
Aboubakar - avatar
0
Thanks.
22nd Jan 2022, 8:35 PM
Asim Farheen ⭐⭐🤺👿👿
Asim  Farheen ⭐⭐🤺👿👿 - avatar