On Tue, 10 Dec 2024, Luis Felipe Hernandez wrote:

> On Tue, Dec 10, 2024 at 02:59:12PM -0500, Nicolas Pitre wrote:
> > This will fail on a 32-bit system where sizeof(long) == 32 and 
> > ULONG_MAX == 4294967295. (meaning the result would be 65535).
> 
> Thank you for taking the time to review my patch and for pointing out the 
> issue with the ULONG_MAX test case. I failed to think about how a 32-bit 
> system would treat ULONG_MAX == 4294967295.
> 
> To address this, I was thinking of updating the test case to use a large 
> enough value that remains within the bounds of unsigned long for both 32-bit 
> and 64-bit architectures instead. Specifically, 2147483648 (2^31), which has 
> an integer square root of 46340. I believe this would ensure the test remains 
> valid and portable across all supported architectures.
> 
> The updated test case would be as follows:
> { 2147483648, 46340, "large input"}

Sure.

And for such kind of test, more values to test is not a bad thing. So 
I'd suggest keeping { 4294967295, 65535 ] as well in the set as this 
represents a nice 
edge case.

It wouldn't hurt adding the entire set from 0 to 9 as well. Many 
different edge cases in that range.


Nicolas

Reply via email to