Radix Sort Floating Data

BGV picture BGV · Jan 15, 2011 · Viewed 7.6k times · Source

How does radix sorts float data? for example 12.4, 45.13 etc. would it read the right side of the decimal point first?or the left side of the decimal point first?And then if it read the right side of the decimal point, how would it treat the numbers, would it first read the rightmost first?

Answer

Winston Ewert picture Winston Ewert · Jan 15, 2011

See this page of a discussion of it.

http://codercorner.com/RadixSortRevisited.htm

Basically, computers store the floating point in a particular format. They do not write it out as 45.13. As a result, thinking about it that way won't relate to how it actually works.

Ignoring that, Radix sort has to look at the most significant part first. In a floating point number that it the left most digits. Essentially, we'd pad all the numbers to have the same number of digits before the decimal point. Then we'd read the digits left to right.