Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions check/features.frm
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,16 @@ assert result("ATANH") =~ expr("
- 6.08698087464190136361e-01*atanh( - 5.4321e-01)
")
*--#] evaluate_atanh :
*--#[ float_zero :
#StartFloat 10d
CFunction f;
Local FloatZero = f(0.0,0.0-123,000.000000,0.0e-13,.0e+4,0e1,0.,0.e+2,0e-10);
Print;
.end
#pend_if wordsize == 2
assert succeeded?
assert result("FloatZero") =~ expr("f(0,-123,0,0,0,0,0,0,0)")
*--#] float_zero :
*--#[ float_error :
Evaluate;
ToFloat;
Expand Down
22 changes: 20 additions & 2 deletions sources/float.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#define GMPSPREAD (GMP_LIMB_BITS/BITSINWORD)

// #define DEBUG

void Form_mpf_init(mpf_t t);
void Form_mpf_clear(mpf_t t);
void Form_mpf_set_prec_raw(mpf_t t,ULONG newprec);
Expand Down Expand Up @@ -273,7 +275,20 @@ int PackFloat(WORD *fun,mpf_t infloat)
mp_limb_t *d = infloat->_mp_d; /* Pointer to the limbs. */
int i;
long e = infloat->_mp_exp;

#ifdef DEBUG
printf("DEBUG: mpf_t internal structure:\n");
printf(" _mp_prec: %d\n", infloat->_mp_prec);
printf(" _mp_size: %d\n", infloat->_mp_size);
printf(" _mp_exp: %ld\n", infloat->_mp_exp);
printf(" _mp_d: %p\n", (void*)infloat->_mp_d);
printf(" Limb values: ");
nlimbs = infloat->_mp_size < 0 ? -infloat->_mp_size: infloat->_mp_size;
for (i = 0; i < nlimbs; i++) {
printf("%ld ", (unsigned long)infloat->_mp_d[i]);
}
printf("\n Actual value: ");
gmp_printf("%.10Fe\n", infloat);
#endif
t = fun;
*t++ = FLOATFUN;
t++;
Expand Down Expand Up @@ -316,6 +331,8 @@ int PackFloat(WORD *fun,mpf_t infloat)
*/
nlimbs = infloat->_mp_size < 0 ? -infloat->_mp_size: infloat->_mp_size;
if ( nlimbs == 0 ) {
*t++ = -SNUMBER;
*t++ = 0;
}
else if ( nlimbs == 1 && (ULONG)(*d) < ((ULONG)1)<<(BITSINWORD-1) ) {
*t++ = -SNUMBER;
Expand Down Expand Up @@ -850,6 +867,7 @@ UBYTE *CheckFloat(UBYTE *ss, int *spec)
GETIDENTITY
UBYTE *s = ss;
int zero = 1, gotdot = 0;
if ( *s == '.' && FG.cTable[s[-1]] != 1 && FG.cTable[s[1]] != 1 ) return(ss);
while ( FG.cTable[s[-1]] == 1 ) s--;
*spec = 0;
if ( FG.cTable[*s] == 1 ) {
Expand All @@ -865,7 +883,7 @@ UBYTE *CheckFloat(UBYTE *ss, int *spec)
dot:
gotdot = 1;
s++;
if ( FG.cTable[*s] != 1 && zero == 1 ) return(ss);
// if ( FG.cTable[*s] != 1 && zero == 1 ) return(ss);
while ( *s == '0' ) s++;
if ( FG.cTable[*s] == 1 ) {
s++;
Expand Down
2 changes: 1 addition & 1 deletion sources/token.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ donumber: i = 0;
in2 = CheckFloat(in,&spec);
if ( in2 > in ) {
if ( spec == 1 ) {
*out++ = TNUMBER; *out++ = 0; s = in2;
*out++ = TNUMBER; *out++ = 0; in = in2;
}
else if ( spec == -1 ) {
MesPrint("&The floating point system has not been started: %s",in);
Expand Down
Loading