=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2018/io/pexpr.c,v retrieving revision 1.4 retrieving revision 1.7 diff -u -p -r1.4 -r1.7 --- OpenXM_contrib2/asir2018/io/pexpr.c 2019/11/12 10:53:23 1.4 +++ OpenXM_contrib2/asir2018/io/pexpr.c 2022/04/03 00:49:25 1.7 @@ -44,7 +44,7 @@ * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. - * $OpenXM: OpenXM_contrib2/asir2018/io/pexpr.c,v 1.3 2019/10/17 03:03:12 kondoh Exp $ + * $OpenXM: OpenXM_contrib2/asir2018/io/pexpr.c,v 1.6 2020/02/01 14:20:42 ohara Exp $ */ #include "ca.h" #include "al.h" @@ -174,31 +174,50 @@ void printbf4itv(BF a) int dprec; char fbuf[BUFSIZ]; char *s; - dprec = (a->body->_mpfr_prec)*0.30103; - if ( !dprec ) dprec = 1; - dprec += 1; - sprintf(fbuf,"%%.%dR%c",dprec,(double_output==1)?'f':(double_output==2)?'e':'g'); - mpfr_asprintf(&s,fbuf,a->body); - TAIL PUTS(s); - mpfr_free_str(s); + + if ( !a ) { + TAIL PUTS("0"); + } + else { + dprec = (a->body->_mpfr_prec)*0.30103; + if ( !dprec ) dprec = 1; + dprec += 1; + sprintf(fbuf,"%%.%dR%c",dprec,(double_output==1)?'f':(double_output==2)?'e':'g'); + mpfr_asprintf(&s,fbuf,a->body); + TAIL PUTS(s); + mpfr_free_str(s); + } } #endif void printz(Z n) { - if ( hex_output == 1 ) { - TAIL PUTS("0x"); - mpz_out_str(OUT,16,BDY(n)); - } else - mpz_out_str(OUT,10,BDY(n)); + printmpz(BDY(n)); } void printmpz(mpz_t z) { +#if !defined(VISUAL) if ( hex_output == 1 ) { TAIL PUTS("0x"); mpz_out_str(OUT,16,z); + } else if ( hex_output == 2 ) { + TAIL PUTS("0b"); + mpz_out_str(OUT,2,z); } else mpz_out_str(OUT,10,z); +#else + char *s; + if ( hex_output == 1 ) { + TAIL PUTS("0x"); + s = mpz_get_str(0,16,z); + } else if ( hex_output == 2 ) { + TAIL PUTS("0b"); + mpz_out_str(0,2,z); + } else { + s = mpz_get_str(0,10,z); + } + TAIL PUTS(s); +#endif }