A method, implemented in hardware logic, for generating and selecting a number, the method comprising: performing a MSB-first iterative generating process for generating a set of n numbers; concurrently with performing the MSB-first iterative generating process for generating the set of n numbers, performing a MSB-first iterative selection process to select either an i th largest or a p th smallest number from the set of n numbers, where i, p and n are integers, wherein performing the MSB-first iterative selection process comprises performing a plurality of iterations, wherein each of the iterations comprises: summing a bit from each of the numbers of the set to generate a summation result, wherein all the bits being summed occupy an identical bit position within their respective number; comparing the summation result to a threshold value (302, 303), wherein the threshold value is calculated based either on i if the i th largest number is selected from the set of n numbers or on p if the p th smallest number is selected from the set of n numbers; setting, based on an outcome of the comparison, a bit of the selected number (305, 307); and for each of the numbers of the set, based on the outcome of the comparison and a value of the bit from the respective number, selectively updating a bit in the respective number occupying a next bit position. and in response to the MSB-first iterative selection process determining that a particular one of the numbers of said set of n numbers will not be the selected number, halting the generation of said particular number by said MSB-first iterative generating process after at least one of the bits of said particular number has been generated and before all of the bits of said particular number have been generated, wherein the method comprises outputting data indicative of the selected number. performing a MSB-first iterative generating process for generating a set of n numbers; concurrently with performing the MSB-first iterative generating process for generating the set of n numbers, performing a MSB-first iterative selection process to select either an i th largest or a p th smallest number from the set of n numbers, where i, p and n are integers, wherein performing the MSB-first iterative selection process comprises performing a plurality of iterations, wherein each of the iterations comprises: summing a bit from each of the numbers of the set to generate a summation result, wherein all the bits being summed occupy an identical bit position within their respective number; comparing the summation result to a threshold value (302, 303), wherein the threshold value is calculated based either on i if the i th largest number is selected from the set of n numbers or on p if the p th smallest number is selected from the set of n numbers; setting, based on an outcome of the comparison, a bit of the selected number (305, 307); and for each of the numbers of the set, based on the outcome of the comparison and a value of the bit from the respective number, selectively updating a bit in the respective number occupying a next bit position. and summing a bit from each of the numbers of the set to generate a summation result, wherein all the bits being summed occupy an identical bit position within their respective number; comparing the summation result to a threshold value (302, 303), wherein the threshold value is calculated based either on i if the i th largest number is selected from the set of n numbers or on p if the p th smallest number is selected from the set of n numbers; setting, based on an outcome of the comparison, a bit of the selected number (305, 307); and for each of the numbers of the set, based on the outcome of the comparison and a value of the bit from the respective number, selectively updating a bit in the respective number occupying a next bit position. and in response to the MSB-first iterative selection process determining that a particular one of the numbers of said set of n numbers will not be the selected number, halting the generation of said particular number by said MSB-first iterative generating process after at least one of the bits of said particular number has been generated and before all of the bits of said particular number have been generated, wherein the method comprises outputting data indicative of the selected number.