Esempio n. 1
0
int wrt_I (unit *ftnunit, uinteger *n, int w, ftnlen len)
{
   int             ndigit, sign, spare;
   int             x;
   char           *ans;
   char		   buf[MAXOCTLENGTH];

   if (len == sizeof (short))
      x = n->is;
   else if (len == sizeof (char))
      x = n->ic;
   else if (len == sizeof (ftnll))
      return (wrt_LL (ftnunit, n, w));
   else
      x = n->ii;
   if (w == 0)
      w = len < 4 ? 7 : 12;
   if (exceed_length(ftnunit, w)) return(110);
   ans = icvt (x, &ndigit, &sign, buf);
   spare = w - ndigit;
   if (sign || ftnunit->f77cplus)
      spare--;
   if (spare < 0)
      PUT (w, '*', NULL);
   else {
      PUT (spare, ' ', NULL);
      if (sign)
	 PUT (1, '-', NULL);
      else if (ftnunit->f77cplus)
	 PUT (1, '+', NULL);
      PUT (ndigit, 0, ans);
   }
   return (0);
}
Esempio n. 2
0
static int wrt_IM (unit *ftnunit, uinteger *n, int w, int m, ftnlen len)
{
   int             ndigit, sign, spare, xsign;
   int             x;
   char           *ans;
   char		   buf[MAXOCTLENGTH];

   if (exceed_length(ftnunit, w)) return(110);
   if (sizeof (short) == len)
      x = n->is;
   else if (len == sizeof (char))
      x = n->ic;
   else if (len == sizeof (ftnll))
      return (wrt_LLM (ftnunit, n, w, m));
   else
      x = n->ii;
   ans = icvt (x, &ndigit, &sign, buf);
   if (sign || ftnunit->f77cplus)
      xsign = 1;
   else
      xsign = 0;
   if (ndigit + xsign > w || m + xsign > w) {
      PUT (w, '*', NULL);
      return (0);
   }
   if (x == 0 && m == 0) {
      PUT (w, ' ', NULL);
      return (0);
   }
   if (ndigit >= m)
      spare = w - ndigit - xsign;
   else
      spare = w - m - xsign;
   PUT (spare, ' ', NULL);
   if (sign)
      PUT (1, '-', NULL);
   else if (ftnunit->f77cplus)
      PUT (1, '+', NULL);
   if (m > ndigit)
      PUT (m - ndigit, '0', NULL);
   PUT (ndigit, 0, ans);
   return (0);
}
Esempio n. 3
0
/* Binary: Assume always fixed length */
char *i2b(lli_t x, int len)
{
  return icvt(x, 2, len, 0);
}
Esempio n. 4
0
char *i2fX(lli_t x, int len)
{
  return icvt(x, 16, len, 0);
}
Esempio n. 5
0
char *i2fx(lli_t x, int len)
{
  return icvt(x, 16, len, 1);
}
Esempio n. 6
0
char *i2vX(lli_t x)
{
  return icvt(x, 16, 0, 0);
}
Esempio n. 7
0
char *i2vx(lli_t x)
{
  return icvt(x, 16, 0, 1);
}
Esempio n. 8
0
/* Decimal */
char *i2d(lli_t x)
{
  return icvt(x, 10, 0, 0);
}