For the non-c guys: Just assume that float to int conversion just truncates the float.ĮDIT: Since we had some confusion here: I need a mapping that maps the smallest input float (0) to the smallest unsigned char, and the highest float of my range (1.0) to the highest unsigned byte (255). How do I do a quantization with equal distribution of the floating point range? Ideally I would like to get a equal distribution of integers if I quantize equal distributed random floats.ītw: Also my code is in C the problem is language-agnostic. Here the the result 0 only cover half of the float-range than any other number.
If I do proper rounding I just shift the problem: The function only returns 255 if a is exactly 1.0f. This works in so far that I get all numbers from 0 to 255, but the distribution of the integers is not even. Sounds like a no-brainer, but infact it's quite compliated: of two floating-point numbers, the mantissas of aligned operands are added. NEXYS 4 DDR (Artix-7) Block Diagram for Programming Logic System. In the Quartus II tools, only multiply and divide by powers of two (shifts).
Say I have a float in the range of and I want to quantize and store it in an unsigned byte. FPGA Floating Point Division (Single Precision) Simple project using the floating point division IP Core's division functionality from Xilinx.