1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-27 19:55:09 +00:00

fix some fallout

This commit is contained in:
mrdudz 2023-08-25 23:04:13 +02:00
parent 92d9e4fcd7
commit fcad1067ad
3 changed files with 21 additions and 10 deletions

View File

@ -149,7 +149,6 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType, int Explicit)
Expr->V.FVal = FP_D_FromInt(Expr->IVal);
LOG(("DoConversion 2 new fval: %f\n", Expr->V.FVal.V));
}
/* FIXME: float --- end of new code */
/* If this is a floating point constant, convert to integer,
** and warn if precision is discarded.
@ -161,6 +160,7 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType, int Explicit)
}
Expr->IVal = IVal;
}
/* FIXME: float --- end of new code */
/* Check if the new datatype will have a smaller range. If it
** has a larger range, things are OK, since the value is

View File

@ -0,0 +1,14 @@
/* Demonstrates that floating point constants are allowed in a limited way.
Value will be converted to an int, with a warning if precision is lost. */
int a = 3.0;
int b = 23.1;
int c = -5.0;
int main(void)
{
if (a != 3) return 1;
if (b != 23) return 2;
if (c != -5) return 3;
return 0;
}

View File

@ -51,11 +51,11 @@ void test1(float f, char *str)
{
if (compare(f, str)) {
// printf(" (ok)");
printf("\n");
} else {
printf(" (failed) !!!\n");
printf(" (failed) !!! ");
result++;
}
printf("result:%d\n", result);
}
void SKIPPEDtest1(float f, char *str)
@ -67,15 +67,12 @@ void SKIPPEDtest1(float f, char *str)
void test(void)
{
#define XMIN 2.0f
#define XSTEP 0.2f
ch = 3;
printf("floatconst + intvar * floatconst\n");
fp1 = XMIN + ch * XSTEP;
printf("fp1:0x%08lx [0x402663e6] %s (2.5997)\n", *((uint32_t*)&fp1), _ftostr(buf, fp1));
test1(fp1, "402663e6");
ch = 3;
fp1 = 2.0f + ch * 0.2f;
printf("fp1:0x%08lx [0x40266666] %s (2.5997)\n", *((uint32_t*)&fp1), _ftostr(buf, fp1));
test1(fp1, "40266666");
ch = 4;
fp1 = ch * 2.0f + 3.0f;