mirror of https://github.com/flysand7/ciabatta.git
Fix some printf bugs and document other
This commit is contained in:
parent
7582b91334
commit
abd8710841
|
@ -773,8 +773,8 @@ static inline int pfx(_dtoa)(
|
|||
// Print decimal point
|
||||
if(decimal_point_n) out('.');
|
||||
// Print fractional part that's made out of digits
|
||||
int prec_digs = prec - mant_digits_n;
|
||||
while(mant_digits_n) {
|
||||
int prec_digs = prec < mant_digits_n ? prec : mant_digits_n;
|
||||
while(mant_digits_n < prec_digs) {
|
||||
if(-exp >= mant_digits_n) {
|
||||
out('0');
|
||||
}
|
||||
|
|
10
test/math.c
10
test/math.c
|
@ -106,15 +106,15 @@ int main() {
|
|||
if(fetestexcept(FE_INVALID)) printf(" FE_INVALID was raised\n");
|
||||
|
||||
printf("\n\n=== exp === \n");
|
||||
printf("exp(1) = %f\n", exp(1));
|
||||
printf("FV of $100, continuously compounded at 3%% for 1 year = %f\n",
|
||||
printf("exp(1) = %e\n", exp(1));
|
||||
printf("FV of $100, continuously compounded at 3%% for 1 year = %e\n",
|
||||
100*exp(0.03));
|
||||
// special values
|
||||
printf("exp(-0) = %f\n", exp(-0.0));
|
||||
printf("exp(-Inf) = %f\n", exp(-INFINITY));
|
||||
printf("exp(-0) = %e\n", exp(-0.0));
|
||||
printf("exp(-Inf) = %e\n", exp(-INFINITY));
|
||||
//error handling
|
||||
errno = 0; feclearexcept(FE_ALL_EXCEPT);
|
||||
printf("exp(710) = %f\n", exp(710));
|
||||
printf("exp(710) = %e\n", exp(710));
|
||||
if(errno == ERANGE) printf(" errno == ERANGE\n");
|
||||
if(fetestexcept(FE_OVERFLOW)) printf(" FE_OVERFLOW raised\n");
|
||||
|
||||
|
|
Loading…
Reference in New Issue