From 8d09250d917acd806df3a7b05e9aee699f570cac Mon Sep 17 00:00:00 2001 From: johanknol Date: Wed, 16 Jan 2002 12:54:10 +0000 Subject: [PATCH] fixed bug #464752 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1805 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCval.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/SDCCval.c b/src/SDCCval.c index 86de5525..59cb5872 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -889,10 +889,28 @@ floatFromVal (value * val) return (double) SPEC_CVAL (val->etype).v_long; } - if (SPEC_USIGN (val->etype)) - return (double) SPEC_CVAL (val->etype).v_uint; - else - return (double) SPEC_CVAL (val->etype).v_int; + if (SPEC_NOUN (val->etype) == V_INT) { + if (SPEC_USIGN (val->etype)) + return (double) SPEC_CVAL (val->etype).v_uint; + else + return (double) SPEC_CVAL (val->etype).v_int; + } + + if (SPEC_NOUN (val->etype) == V_CHAR) { + if (SPEC_USIGN (val->etype)) + return (double) (unsigned char)SPEC_CVAL (val->etype).v_uint; + else + return (double) (signed char)SPEC_CVAL (val->etype).v_int; + } + + if (IS_BITVAR(val->etype)) { + return (double) SPEC_CVAL (val->etype).v_ulong; + } + + // we are lost ! + werror (E_INTERNAL_ERROR, __FILE__, __LINE__, + "floatFromVal: unknown value"); + return 0; } -- 2.30.2