~sircmpwn/harec unlisted

e22381505cb8c9e2d0598d3ff77e342b0376d6cb — Eyal Sawady a month ago b5ae44e
eval_cast: fix integer -> float casts

Signed-off-by: Eyal Sawady <ecs@d2evs.net>
1 files changed, 10 insertions(+), 1 deletions(-)

M src/eval.c
M src/eval.c => src/eval.c +10 -1
@@ 424,7 424,16 @@ eval_cast(struct context *ctx, struct expression *in, struct expression *out)
	case STORAGE_F32:
	case STORAGE_F64:
	case STORAGE_FCONST:
		out->constant.fval = ftrunc(to, val.constant.fval);
		if (type_is_float(val.result)) {
			out->constant.fval = ftrunc(to, val.constant.fval);
		} else if (type_is_signed(val.result)) {
			out->constant.fval =
				ftrunc(to, (double)val.constant.ival);
		} else {
			assert(type_is_integer(val.result));
			out->constant.fval =
				ftrunc(to, (double)val.constant.uval);
		}
		return EVAL_OK;
	case STORAGE_CHAR:
	case STORAGE_ENUM: