Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Voxera116407yIn a function like that I suggest you go all out and compare with the octal number instead of a char ;)
-
Using the heap instead of the stack to create a fixed size array and not even free it afterwards, all that to sprintf the sign. I'm having a hard time thinking how to make it any worse. You are a genius! :)
Such efficient, much wow. -
xwing71297yIn the internal representation, there is 1 bit for the sign (S), 8 bits for the exponent (E), and 23 bits for the fraction (F). The bits are mapped with the fraction in bit 0 to bit 22, the exponent in bit 23 to bit 30, and the sign in bit 31.
so code:
static bool IsNagative (float numb)
{
if(numb >> 31)
{
return true;
}
return false;
}
no memory allocation needed and if you don't want a copy of the float variable then use references.
How to check if a number is negative.
undefined