mirror of
https://github.com/cc65/cc65.git
synced 2024-11-20 12:32:58 +00:00
cleanup
This commit is contained in:
parent
e8e39db4ca
commit
7370478f80
@ -9,38 +9,30 @@ char *_ftostr(char *buffer, float f) {
|
||||
signed long n0;
|
||||
int is_negative;
|
||||
unsigned long raw_value = *((unsigned long*)(&f));
|
||||
|
||||
// f = -1.23f;
|
||||
|
||||
|
||||
is_negative = (raw_value & 0x80000000) ? 1 : 0; // very hacky indeed
|
||||
|
||||
intpart = (signed long)(f);
|
||||
if (intpart < 0) {
|
||||
intpart *= -1;
|
||||
}
|
||||
|
||||
is_negative = (raw_value & 0x80000000) ? 1 : 0;
|
||||
|
||||
// printf("f:%f\n",f);
|
||||
|
||||
f2 = intpart;
|
||||
// printf("f2:%f\n",f2);
|
||||
// printf("f2:%08lx\n",*((unsigned long*)(&f2)));
|
||||
|
||||
if (f2 > f) {
|
||||
if (intpart > 0) {
|
||||
--intpart;
|
||||
}
|
||||
}
|
||||
|
||||
if (intpart < 0) {
|
||||
intpart *= -1;
|
||||
}
|
||||
|
||||
f2 = intpart;
|
||||
fracpart = f - f2;
|
||||
// printf("fracpart:%f\n",fracpart);
|
||||
// printf("fracpart:%08lx\n",*((unsigned long*)(&fracpart)));
|
||||
// f1 = fracpart * 10000.0f;
|
||||
|
||||
f1 = 10000.0f;
|
||||
// printf("fracpart:%08lx\n",*((unsigned long*)(&f1)));
|
||||
// f1 *= fracpart;
|
||||
|
||||
f1 = f1 * fracpart;
|
||||
// f1 = fracpart;
|
||||
// f1 = intpart;
|
||||
// printf("fracpart:%f\n",f1);
|
||||
// printf("fracpart:%08lx\n",*((unsigned long*)(&f1)));
|
||||
|
||||
n0 = (signed long)f1;
|
||||
if (n0 < 0) {
|
||||
n0 *= -1;
|
||||
|
Loading…
Reference in New Issue
Block a user