Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Thank you for creating and sharing this example. I think the fact of merely loading a shared library as modifying the FP behavior is the real shocker, more than any particular FP computation that hinges on denormals.

Still, I think one of the great wins with denormals is that they make "x == y iff x-y == 0" true; absent denormals you can have two normalized x and y, x != y, such y-x evaluates to 0. So for an example, maybe something that involves y > x and yet ceil(y-x) == 0, which is surprising. The only setting I can think of is something like making a histogram (with flipped indices, like your pixel row) of differences of values, so that ceil(y-x) == 0 leads to an invalid histogram index.

Some values are x=1e-32 and y=1.0000011e-32, which parse (via sscanf) to:

   x = 0:00010100:10011111011000100011111 = (-1)^0 * 2^( 20-127) * (1+5222687/2^23)
   y = 0:00010100:10011111011000100101110 = (-1)^0 * 2^( 20-127) * (1+5222702/2^23)
and then the denormalized difference d = x-y should be:

   d = 0:00000000:11110000000000000000000 = (-1)^0 *  2^(1-127)  * (0+7864320/2^23)
Having some specific values sidesteps concerns about nextafterf(). In this case I think y is many ulps above x, not just 1.


Thanks for this excellent idea! I implemented it in this histogram plotting demo:

https://github.com/moyix/2_ffast_2_furious


Holy moly you've converted my little idea into a lovely demo! Thanks for showcasing this and sorry to be slow to notice.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: