numparam, almost full precision for stringified double float numbers
This commit is contained in:
parent
6a2060e472
commit
492f1f006c
|
|
@ -59,7 +59,7 @@ extern int dynmaxline; /* inpcom.c:1529 */
|
|||
overwrite any line pointers, or we start a new set after each sig=0 ?
|
||||
Anyway, we neutralize all & and .param lines (category[] array!)
|
||||
and we substitute all {} &() and &id placeholders by dummy identifiers.
|
||||
those look like numparm__XXXXXXXX (8 hexadecimal digits)
|
||||
those look like numparm__________XXXXXXXX (8 hexadecimal digits)
|
||||
|
||||
*/
|
||||
/********** string handling ***********/
|
||||
|
|
@ -135,8 +135,8 @@ stripbraces(SPICE_DSTRINGPTR dstr_p)
|
|||
|
||||
cadd(&tstr, ' ');
|
||||
{
|
||||
char buf[17+1];
|
||||
sprintf(buf, "numparm__%08lx", placeholder);
|
||||
char buf[25+1];
|
||||
sprintf(buf, "numparm__________%08lx", placeholder);
|
||||
sadd(&tstr, buf);
|
||||
}
|
||||
cadd(&tstr, ' ');
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ extern double drand(void);
|
|||
extern char *nupa_inst_name; /* see spicenum.c */
|
||||
extern long dynsubst; /* see inpcom.c */
|
||||
|
||||
#define MAX_STRING_INSERT 17 /* max. string length to be inserted and replaced */
|
||||
#define ACT_CHARACTS 17 /* actual string length to be inserted and replaced */
|
||||
#define EXP_LENGTH 5
|
||||
#define ACT_CHARACTS 25 /* actual string length to be inserted and replaced */
|
||||
|
||||
#define S_init 0
|
||||
#define S_atom 1
|
||||
|
|
@ -1295,14 +1293,14 @@ evaluate(tdico *dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
|
|||
}
|
||||
|
||||
if (numeric) {
|
||||
/* we want *exactly* 17 chars, we have
|
||||
/* we want *exactly* 25 chars, we have
|
||||
* sign, leading digit, '.', 'e', sign, upto 3 digits exponent
|
||||
* ==> 8 chars, thus we have 9 left for precision
|
||||
* ==> 8 chars, thus we have 17 left for precision
|
||||
* don't print a leading '+', something choked
|
||||
*/
|
||||
|
||||
char buf[17+1];
|
||||
if (snprintf(buf, sizeof(buf), "% 17.9e", u) != 17) {
|
||||
char buf[ACT_CHARACTS + 1];
|
||||
if (snprintf(buf, sizeof(buf), "% 25.17e", u) != ACT_CHARACTS) {
|
||||
fprintf(stderr, "ERROR: xpressn.c, %s(%d)\n", __FUNCTION__, __LINE__);
|
||||
controlled_exit(1);
|
||||
}
|
||||
|
|
@ -1486,13 +1484,13 @@ insertnumber(tdico *dico, int i, char *s, SPICE_DSTRINGPTR ustr_p)
|
|||
long id = 0;
|
||||
int n = 0;
|
||||
|
||||
char *p = strstr(s+i, "numparm__");
|
||||
char *p = strstr(s+i, "numparm__________");
|
||||
|
||||
if (p &&
|
||||
(1 == sscanf(p, "numparm__%8lx%n", &id, &n)) &&
|
||||
(1 == sscanf(p, "numparm__________%8lx%n", &id, &n)) &&
|
||||
(n == ACT_CHARACTS) &&
|
||||
(id > 0) && (id < dynsubst + 1) &&
|
||||
(snprintf(buf, sizeof(buf), "%-17s", u) == ACT_CHARACTS))
|
||||
(snprintf(buf, sizeof(buf), "%-25s", u) == ACT_CHARACTS))
|
||||
{
|
||||
memcpy(p, buf, ACT_CHARACTS);
|
||||
return (int)(p - s) + ACT_CHARACTS;
|
||||
|
|
|
|||
Loading…
Reference in New Issue