Skip to content

Instantly share code, notes, and snippets.

@pandax381
Last active August 17, 2017 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandax381/65662c409366b7887e406ade783a4bfb to your computer and use it in GitHub Desktop.
Save pandax381/65662c409366b7887e406ade783a4bfb to your computer and use it in GitHub Desktop.
Berkeley SoftFloat test
#include <stdio.h>
#include "softfloat.h"
int
main (void) {
float32_t a = ui32_to_f32(0x3F800000); /* 1.0 */
float32_t b = ui32_to_f32(0x40000000); /* 2.0 */
float32_t c = f32_add(a, b);
fprintf(stderr, "0x%lx + 0x%lx = 0x%lx\n",
f32_to_ui32(a, softfloat_round_near_even, true),
f32_to_ui32(b, softfloat_round_near_even, true),
f32_to_ui32(c, softfloat_round_near_even, true)
);
return 0;
}
@pandax381
Copy link
Author

$ ./softfloat_test 
0x3f800000 + 0x40000000 = 0x7f800000

@pandax381
Copy link
Author

Berkeley SoftFloat (Release 3d)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment