mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Merge branch 'master' of https://github.com/10110111/calc into 10110111-master
This commit is contained in:
1
config.c
1
config.c
@@ -274,6 +274,7 @@ STATIC NAMETYPE modes[] = {
|
|||||||
{"oct", MODE_OCTAL},
|
{"oct", MODE_OCTAL},
|
||||||
{"binary", MODE_BINARY},
|
{"binary", MODE_BINARY},
|
||||||
{"bin", MODE_BINARY},
|
{"bin", MODE_BINARY},
|
||||||
|
{"float-auto", MODE_REAL_AUTO},
|
||||||
{"off", MODE2_OFF},
|
{"off", MODE2_OFF},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
3
file.c
3
file.c
@@ -1031,6 +1031,9 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
|
|||||||
case 'e':
|
case 'e':
|
||||||
newmode = MODE_EXP;
|
newmode = MODE_EXP;
|
||||||
break;
|
break;
|
||||||
|
case 'g':
|
||||||
|
newmode = MODE_REAL_AUTO;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
newmode = MODE_FRAC;
|
newmode = MODE_FRAC;
|
||||||
break;
|
break;
|
||||||
|
21
qio.c
21
qio.c
@@ -233,6 +233,27 @@ qprintnum(NUMBER *q, int outmode)
|
|||||||
PRINTF1("e%ld", exp);
|
PRINTF1("e%ld", exp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MODE_REAL_AUTO:
|
||||||
|
{
|
||||||
|
const int P = conf->outdigits ? conf->outdigits : 1;
|
||||||
|
tmpval = *q;
|
||||||
|
tmpval.num.sign = 0;
|
||||||
|
exp = qilog10(&tmpval);
|
||||||
|
const long olddigits = conf->outdigits;
|
||||||
|
if(P > exp && exp >= -4)
|
||||||
|
{
|
||||||
|
conf->outdigits = P - 1 - exp;
|
||||||
|
qprintnum(q, MODE_REAL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
conf->outdigits = P - 1;
|
||||||
|
qprintnum(q, MODE_EXP);
|
||||||
|
}
|
||||||
|
conf->outdigits = olddigits;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MODE_HEX:
|
case MODE_HEX:
|
||||||
qprintfx(q, 0L);
|
qprintfx(q, 0L);
|
||||||
break;
|
break;
|
||||||
|
5
zmath.h
5
zmath.h
@@ -579,10 +579,11 @@ E_FUNC void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
|||||||
#define MODE_HEX 5
|
#define MODE_HEX 5
|
||||||
#define MODE_OCTAL 6
|
#define MODE_OCTAL 6
|
||||||
#define MODE_BINARY 7
|
#define MODE_BINARY 7
|
||||||
#define MODE_MAX 7
|
#define MODE_REAL_AUTO 8
|
||||||
|
#define MODE_MAX 8
|
||||||
#define MODE2_OFF (MODE_MAX+1)
|
#define MODE2_OFF (MODE_MAX+1)
|
||||||
|
|
||||||
#define MODE_INITIAL MODE_REAL
|
#define MODE_INITIAL MODE_REAL_AUTO
|
||||||
#define MODE2_INITIAL MODE2_OFF
|
#define MODE2_INITIAL MODE2_OFF
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user