Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- static float fnms(float a, float b, float c)
- {
- return (float) -((double) a * (double) b - (double) c);
- }
- int main()
- {
- union
- {
- float f;
- unsigned u;
- } u;
- const float a = 255.0f;
- const float aScaled = -a * pow(2.0f, 23.0f);
- for (int b=0; b < 65536; b++)
- {
- u.u = 0x3f800000 | b;
- float product = fnms(u.f, aScaled, aScaled);
- int prodAsInt = (int) product;
- if (prodAsInt != a*b)
- {
- printf("Mismatch! b=%d\n", b);
- return 1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement