Every modern hardware, including embedded devices, should support floating point numbers.
This commit is contained in:
parent
0a9cfce672
commit
9ee0f1954c
@ -3267,7 +3267,6 @@ struct ph7_fmt_info {
|
|||||||
const char *charset; /* The character set for conversion */
|
const char *charset; /* The character set for conversion */
|
||||||
const char *prefix; /* Prefix on non-zero values in alt format */
|
const char *prefix; /* Prefix on non-zero values in alt format */
|
||||||
};
|
};
|
||||||
#ifndef PH7_OMIT_FLOATING_POINT
|
|
||||||
/*
|
/*
|
||||||
** "*val" is a double such that 0.1 <= *val < 10.0
|
** "*val" is a double such that 0.1 <= *val < 10.0
|
||||||
** Return the ascii code for the leading digit of *val, then
|
** Return the ascii code for the leading digit of *val, then
|
||||||
@ -3292,7 +3291,6 @@ static int vxGetdigit(sxlongreal *val, int *cnt) {
|
|||||||
*val = (*val - d) * 10.0;
|
*val = (*val - d) * 10.0;
|
||||||
return digit + '0' ;
|
return digit + '0' ;
|
||||||
}
|
}
|
||||||
#endif /* PH7_OMIT_FLOATING_POINT */
|
|
||||||
/*
|
/*
|
||||||
* The following table is searched linearly, so it is good to put the most frequently
|
* The following table is searched linearly, so it is good to put the most frequently
|
||||||
* used conversion types first.
|
* used conversion types first.
|
||||||
@ -3621,7 +3619,6 @@ PH7_PRIVATE sxi32 PH7_InputFormat(
|
|||||||
case PH7_FMT_FLOAT:
|
case PH7_FMT_FLOAT:
|
||||||
case PH7_FMT_EXP:
|
case PH7_FMT_EXP:
|
||||||
case PH7_FMT_GENERIC: {
|
case PH7_FMT_GENERIC: {
|
||||||
#ifndef PH7_OMIT_FLOATING_POINT
|
|
||||||
long double realvalue;
|
long double realvalue;
|
||||||
int exp; /* exponent of real numbers */
|
int exp; /* exponent of real numbers */
|
||||||
double rounder; /* Used for rounding floating point values */
|
double rounder; /* Used for rounding floating point values */
|
||||||
@ -3804,10 +3801,6 @@ PH7_PRIVATE sxi32 PH7_InputFormat(
|
|||||||
}
|
}
|
||||||
length = width;
|
length = width;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
zBuf = " ";
|
|
||||||
length = (int)sizeof(char);
|
|
||||||
#endif /* PH7_OMIT_FLOATING_POINT */
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -30,12 +30,6 @@
|
|||||||
* point value is out of range.
|
* point value is out of range.
|
||||||
*/
|
*/
|
||||||
static sxi64 MemObjRealToInt(ph7_value *pObj) {
|
static sxi64 MemObjRealToInt(ph7_value *pObj) {
|
||||||
#ifdef PH7_OMIT_FLOATING_POINT
|
|
||||||
/* Real and 64bit integer are the same when floating point arithmetic
|
|
||||||
* is omitted from the build.
|
|
||||||
*/
|
|
||||||
return pObj->rVal;
|
|
||||||
#else
|
|
||||||
/*
|
/*
|
||||||
** Many compilers we encounter do not define constants for the
|
** Many compilers we encounter do not define constants for the
|
||||||
** minimum and maximum 64-bit integers, or they define them
|
** minimum and maximum 64-bit integers, or they define them
|
||||||
@ -57,7 +51,6 @@ static sxi64 MemObjRealToInt(ph7_value *pObj) {
|
|||||||
} else {
|
} else {
|
||||||
return (sxi64)r;
|
return (sxi64)r;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Convert a raw token value typically a stream of digit [i.e: hex,octal,binary or decimal]
|
* Convert a raw token value typically a stream of digit [i.e: hex,octal,binary or decimal]
|
||||||
@ -190,27 +183,15 @@ static ph7_real MemObjRealValue(ph7_value *pObj) {
|
|||||||
return (ph7_real)pObj->x.iVal;
|
return (ph7_real)pObj->x.iVal;
|
||||||
} else if(iFlags & MEMOBJ_STRING) {
|
} else if(iFlags & MEMOBJ_STRING) {
|
||||||
SyString sString;
|
SyString sString;
|
||||||
#ifdef PH7_OMIT_FLOATING_POINT
|
|
||||||
ph7_real rVal = 0;
|
|
||||||
#else
|
|
||||||
ph7_real rVal = 0.0;
|
ph7_real rVal = 0.0;
|
||||||
#endif
|
|
||||||
SyStringInitFromBuf(&sString, SyBlobData(&pObj->sBlob), SyBlobLength(&pObj->sBlob));
|
SyStringInitFromBuf(&sString, SyBlobData(&pObj->sBlob), SyBlobLength(&pObj->sBlob));
|
||||||
if(SyBlobLength(&pObj->sBlob) > 0) {
|
if(SyBlobLength(&pObj->sBlob) > 0) {
|
||||||
/* Convert as much as we can */
|
/* Convert as much as we can */
|
||||||
#ifdef PH7_OMIT_FLOATING_POINT
|
|
||||||
rVal = MemObjStringToInt(&(*pObj));
|
|
||||||
#else
|
|
||||||
SyStrToReal(sString.zString, sString.nByte, (void *)&rVal, 0);
|
SyStrToReal(sString.zString, sString.nByte, (void *)&rVal, 0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
} else if(iFlags & MEMOBJ_NULL) {
|
} else if(iFlags & MEMOBJ_NULL) {
|
||||||
#ifdef PH7_OMIT_FLOATING_POINT
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
return 0.0;
|
return 0.0;
|
||||||
#endif
|
|
||||||
} else if(iFlags & MEMOBJ_HASHMAP) {
|
} else if(iFlags & MEMOBJ_HASHMAP) {
|
||||||
/* Return the total number of entries in the hashmap */
|
/* Return the total number of entries in the hashmap */
|
||||||
ph7_hashmap *pMap = (ph7_hashmap *)pObj->x.pOther;
|
ph7_hashmap *pMap = (ph7_hashmap *)pObj->x.pOther;
|
||||||
@ -296,11 +277,7 @@ static sxi32 MemObjBooleanValue(ph7_value *pObj) {
|
|||||||
sxi32 iFlags;
|
sxi32 iFlags;
|
||||||
iFlags = pObj->iFlags;
|
iFlags = pObj->iFlags;
|
||||||
if(iFlags & MEMOBJ_REAL) {
|
if(iFlags & MEMOBJ_REAL) {
|
||||||
#ifdef PH7_OMIT_FLOATING_POINT
|
|
||||||
return pObj->rVal ? 1 : 0;
|
|
||||||
#else
|
|
||||||
return pObj->rVal != 0.0 ? 1 : 0;
|
return pObj->rVal != 0.0 ? 1 : 0;
|
||||||
#endif
|
|
||||||
} else if(iFlags & MEMOBJ_INT) {
|
} else if(iFlags & MEMOBJ_INT) {
|
||||||
return pObj->x.iVal ? 1 : 0;
|
return pObj->x.iVal ? 1 : 0;
|
||||||
} else if(iFlags & MEMOBJ_STRING) {
|
} else if(iFlags & MEMOBJ_STRING) {
|
||||||
|
@ -127,11 +127,6 @@ typedef struct ph7 ph7;
|
|||||||
* PH7_DISABLE_DISK_IO
|
* PH7_DISABLE_DISK_IO
|
||||||
* If this directive is enabled, built-in Virtual File System functions such as
|
* If this directive is enabled, built-in Virtual File System functions such as
|
||||||
* chdir(), mkdir(), chroot(), unlink(), delete(), etc. are omitted from the build.
|
* chdir(), mkdir(), chroot(), unlink(), delete(), etc. are omitted from the build.
|
||||||
* PH7_OMIT_FLOATING_POINT
|
|
||||||
* This option is used to omit floating-point number support from the PH7 library
|
|
||||||
* if compiling for a processor that lacks floating point support. When specified
|
|
||||||
* the library will substitute 64-bit integer arithmetic for floating-point which
|
|
||||||
* mean that 25.e-3 and 25 are equals and are of type integer.
|
|
||||||
*/
|
*/
|
||||||
/* Symisc public definitions */
|
/* Symisc public definitions */
|
||||||
#if !defined(SYMISC_STANDARD_DEFS)
|
#if !defined(SYMISC_STANDARD_DEFS)
|
||||||
@ -311,11 +306,7 @@ struct SyMutexMethods {
|
|||||||
* If compiling for a processor that lacks floating point
|
* If compiling for a processor that lacks floating point
|
||||||
* support, substitute integer for floating-point.
|
* support, substitute integer for floating-point.
|
||||||
*/
|
*/
|
||||||
#ifdef PH7_OMIT_FLOATING_POINT
|
typedef double ph7_real;
|
||||||
typedef sxi64 ph7_real;
|
|
||||||
#else
|
|
||||||
typedef double ph7_real;
|
|
||||||
#endif
|
|
||||||
typedef sxi64 ph7_int64;
|
typedef sxi64 ph7_int64;
|
||||||
#define PH7_APIEXPORT SX_APIEXPORT
|
#define PH7_APIEXPORT SX_APIEXPORT
|
||||||
#define PH7_APIIMPORT SX_APIIMPORT
|
#define PH7_APIIMPORT SX_APIIMPORT
|
||||||
|
Loading…
Reference in New Issue
Block a user