Skip to content

Instantly share code, notes, and snippets.

@pandax381
Created August 17, 2017 04:02
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/20bc6e972cb787a6db30758200a67730 to your computer and use it in GitHub Desktop.
Save pandax381/20bc6e972cb787a6db30758200a67730 to your computer and use it in GitHub Desktop.
Berkeley SoftFloat test 2
#include <stdio.h>
#include "softfloat.h"
int
main (void) {
float32_t a = {0x3F800000};
float32_t b = {0x40000000};
float32_t c = f32_add(a, b);
fprintf(stderr, "0x%x (%ld) + 0x%x (%ld) = 0x%x (%ld)\n",
(uint32_t)a.v, f32_to_ui32(a, softfloat_round_near_even, true),
(uint32_t)b.v, f32_to_ui32(b, softfloat_round_near_even, true),
(uint32_t)c.v, f32_to_ui32(c, softfloat_round_near_even, true)
);
return 0;
}
@pandax381
Copy link
Author

$ softfloat_test2
0x3f800000 (1) + 0x40000000 (2) = 0x40400000 (3)

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