Page Menu
Home
Search
Configure Global Search
Log In
Paste
P2740
(An Untitled Masterwork)
Active
Public
Actions
Authored by
Ray Molenkamp (LazyDodo)
on Jan 14 2022, 8:11 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#define float_as_uint(f) (*(uint32_t*)&f)
#define uint_as_float(f) (*(float*)&f)
int main()
{
uint32_t val = 0xbe9127f4;
float f = uint_as_float(val);
float y = acosf(f);
uint32_t o_val = float_as_uint(y);
// to rule out any differences in formatter print the float
// value in hex.
printf("val = %.8x\n", o_val);
printf("val = %.9f\n", y);
return 0;
}
// output on windows
// val = 3feddb05
// val = 1.858246446
// output on linux
//val = 3feddb06
//val = 1.858246565
Event Timeline
Ray Molenkamp (LazyDodo)
created this paste.
Jan 14 2022, 8:11 PM
Log In to Comment