X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=fold.c;h=af37c4c76f652c7e083f02ffa55e7188de0bc5f8;hp=3d3041d9414b9ad7e75d1dafdbd90e623f571baa;hb=05b349c72f622292703f301c410704c2320382f4;hpb=2024b3bd7179b3b5a3033c9f485e9fa88e3086dc diff --git a/fold.c b/fold.c index 3d3041d..af37c4c 100644 --- a/fold.c +++ b/fold.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013 + * Copyright (C) 2012, 2013, 2014 * Dale Weiler * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -550,13 +550,13 @@ static GMQCC_INLINE ast_expression *fold_op_xor(fold_t *fold, ast_value *a, ast_ static GMQCC_INLINE ast_expression *fold_op_lshift(fold_t *fold, ast_value *a, ast_value *b) { if (fold_can_2(a, b) && isfloats(a, b)) - return fold_constgen_float(fold, (qcfloat_t)((qcuint_t)(fold_immvalue_float(a)) << (qcuint_t)(fold_immvalue_float(b)))); + return fold_constgen_float(fold, (qcfloat_t)floorf(fold_immvalue_float(a) * powf(2.0f, fold_immvalue_float(b)))); return NULL; } static GMQCC_INLINE ast_expression *fold_op_rshift(fold_t *fold, ast_value *a, ast_value *b) { if (fold_can_2(a, b) && isfloats(a, b)) - return fold_constgen_float(fold, (qcfloat_t)((qcuint_t)(fold_immvalue_float(a)) >> (qcuint_t)(fold_immvalue_float(b)))); + return fold_constgen_float(fold, (qcfloat_t)floorf(fold_immvalue_float(a) / powf(2.0f, fold_immvalue_float(b)))); return NULL; } @@ -729,7 +729,7 @@ static GMQCC_INLINE ast_expression *fold_intrin_asinh(fold_t *fold, ast_value *a return fold_constgen_float(fold, asinhf(fold_immvalue_float(a))); } static GMQCC_INLINE ast_expression *fold_intrin_atanh(fold_t *fold, ast_value *a) { - return fold_constgen_float(fold, atanhf(fold_immvalue_float(a))); + return fold_constgen_float(fold, (float)atanh(fold_immvalue_float(a))); } static GMQCC_INLINE ast_expression *fold_intrin_exp(fold_t *fold, ast_value *a) { return fold_constgen_float(fold, expf(fold_immvalue_float(a)));