Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max unsigned integer trouble #1

Open
GoogleCodeExporter opened this issue May 4, 2015 · 2 comments
Open

Max unsigned integer trouble #1

GoogleCodeExporter opened this issue May 4, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Hi! My name is Jose Luis Cercós Pita, and i will implement your radix sort 
implementation in my code.

I'm using 0-2 version.

The problem is associated to _MAXINT defined variable (CLRadixSortParam.hpp). 
If the unsigned integer type selected has 32 bits (#define _TOTALBITS 32) 
_MAXINT overflows the maximum capability of the unsigned int type (because 2^0 
has not taken into account).

In order to solve it, I suggest you 3 changes:

CLRadixSortParam.hpp (line 31):
[-] #define _MAXINT (1 << _TOTALBITS)
[+] #define _MAXINT (1 << (_TOTALBITS-1))

CLRadixSort.cpp (line 225):
[-] int pad[_GROUPS * _ITEMS];
[+] unsigned int pad[_GROUPS * _ITEMS];

CLRadixSort.cpp (line 227):
[-] pad[ii]=_MAXINT - 1;
[+] pad[ii]=_MAXINT - (unsigned int)1;

I tested it, and runs OK!
I hope can help!

Regards,
Jose Luis Cercós Pita

Original issue reported on code.google.com by [email protected] on 19 May 2011 at 8:23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant