LP live advanced doubt

during 52-53 min instructor states the reason of negative ans in case of large no. multiplication please state clearly why we get negative number while multiplying large no.

Signed int in C/C++ is 4 bytes and the value range is from –2,147,483,648 to 2,147,483,647. If the value of a signed int is greater than 2,147,483,647, it causes an overflow which can result in a negative number.
If you use an unsigned int instead (if you’re certain that the variable can never actually contain a negative number), it is also 4 bytes and the value range is from 0 to 4,294,967,295.
If that is still too limiting, you can use a long long variable which is 8 bytes and the value range is from –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 or unsigned long long with a value range from 0 to 18,446,744,073,709,551,615.

Hope this helps :slight_smile:

yes I know this but why we always gets negative values?? why not positive some garbage values

also in the video the instructor says code has been saved to ide 237 of hashtable where can I get the code link , video reference time - 1:45:59 since the video here is of 2017 I don’t know which link he is talking about, please provide code of hash table he has written

See it can become any value depending on how big the numbers are. It is because after the INT_MAX the numbers start from INT_MIN Again in a circular fashion.

So if let us consider the limit of char which is -128 to 127.
The next number after 127 would be -128 then -127 and so on upto 0 .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.