UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
122 Views
Registered: ‎04-19-2018

Is there any problem with half (float)?

Half doesn't seem to work... even a product is apparently wrong.

Is there something special to do, besides including "hls_half.h" and declaring variables as 'half'?

0 Kudos
2 Replies
Voyager
Voyager
88 Views
Registered: ‎10-23-2018

Re: Is there any problem with half (float)?

@satguy

May need some additional info, but based on the fact you used 'product'... a product 'may' take more space than the terms being multiplied. Also, the magnitude of the value is expected to be in a very specific range...

• 1 signed bit
• 5 exponent bits
• 10 mantissa bits

Also, are you using the 'helper' function to print the result, or just a normal 'float' print and not casting? (e.g. maybe your value is fine, just you are displaying it wrong?) 

Hope that helps

If so, please mark as solution accepted. Kudos also welcomed :-)

0 Kudos
Adventurer
Adventurer
78 Views
Registered: ‎04-19-2018

Re: Is there any problem with half (float)?

@xilinxacct

I'm using half as I don't need neither the float range or accuracy. Is actually nonsensical to have 10 digit resolution to produce a result that is good if within 10% of what is right.

The numbers I was multiplying were in the range of the tens... I first printed them out to the console straight away. Got zero. Then added a cast to float. Zero again... mmm... then debugger, added a watch to the variable with a cast to float..surprise!! I could see something like 0.1 * 0.5 being something like 1e-20.

I will try to repeat, document and attach the experiment and results

0 Kudos