You've got a typo in the first two math equations, instead of r variable, b should be used.
long is platform dependant (has 4 bytes on 32 bit platforms, then you have to use long long or __int64 (eg. look here https://msdn.microsoft.com/en-us/en-en/library/s3f49ktz.aspx)).
The most correct way of doing this is to use stdint.h header (from C99) and then use int64_t which is platform independant and is always 64bit.
ExtendedTest3 ✘ Expected: equal to 4000000000 Actual: -294967296
C++ version has prototype: long sumTwoSmallestNumbers(std::vector n), it is IMPOSSIBLE to have 4000000000 as answer
It is rather bad as 9999999999 overflows (0x2_540B_E3FF) and 32 bit architectures use 0x7FFFFFFF as max for signed int.
This comment is hidden because it contains spoiler information about the solution
Loading collection data...
You've got a typo in the first two math equations, instead of r variable, b should be used.
long is platform dependant (has 4 bytes on 32 bit platforms, then you have to use long long or __int64 (eg. look here https://msdn.microsoft.com/en-us/en-en/library/s3f49ktz.aspx)).
The most correct way of doing this is to use stdint.h header (from C99) and then use int64_t which is platform independant and is always 64bit.
ExtendedTest3
✘ Expected: equal to 4000000000
Actual: -294967296
C++ version has prototype: long sumTwoSmallestNumbers(std::vector n), it is IMPOSSIBLE to have 4000000000 as answer
It is rather bad as 9999999999 overflows (0x2_540B_E3FF) and 32 bit architectures use 0x7FFFFFFF as max for signed int.
This comment is hidden because it contains spoiler information about the solution