Reputation: 6030
Let's assume float f = 4.4
If I browse f
in some memory reader and assume that f
is an int
I get the value 1082969293.
I don't want to cast it to int like (int)f
Is there a way to assume f as int and get that value(1082969293) in C# ?
Upvotes: 1
Views: 214
Reputation: 144136
float f = 4.4f;
var bytes = BitConverter.GetBytes(f);
int i = BitConverter.ToInt32(bytes, 0);
Upvotes: 8