OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [stdlib/] [efgcvt.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/*
/*
FUNCTION
FUNCTION
<<ecvt>>, <<ecvtf>>, <<fcvt>>, <<fcvtf>>---double or float to string
<<ecvt>>, <<ecvtf>>, <<fcvt>>, <<fcvtf>>---double or float to string
 
 
INDEX
INDEX
        ecvt
        ecvt
INDEX
INDEX
        ecvtf
        ecvtf
INDEX
INDEX
        fcvt
        fcvt
INDEX
INDEX
        fcvtf
        fcvtf
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
 
 
        char *ecvt(double <[val]>, int <[chars]>, int *<[decpt]>, int *<[sgn]>);
        char *ecvt(double <[val]>, int <[chars]>, int *<[decpt]>, int *<[sgn]>);
        char *ecvtf(float <[val]>, int <[chars]>, int *<[decpt]>, int *<[sgn]>);
        char *ecvtf(float <[val]>, int <[chars]>, int *<[decpt]>, int *<[sgn]>);
 
 
        char *fcvt(double <[val]>, int <[decimals]>,
        char *fcvt(double <[val]>, int <[decimals]>,
                   int *<[decpt]>, int *<[sgn]>);
                   int *<[decpt]>, int *<[sgn]>);
        char *fcvtf(float <[val]>, int <[decimals]>,
        char *fcvtf(float <[val]>, int <[decimals]>,
                    int *<[decpt]>, int *<[sgn]>);
                    int *<[decpt]>, int *<[sgn]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
 
 
        char *ecvt(<[val]>, <[chars]>, <[decpt]>, <[sgn]>);
        char *ecvt(<[val]>, <[chars]>, <[decpt]>, <[sgn]>);
        double <[val]>;
        double <[val]>;
        int <[chars]>;
        int <[chars]>;
        int *<[decpt]>;
        int *<[decpt]>;
        int *<[sgn]>;
        int *<[sgn]>;
        char *ecvtf(<[val]>, <[chars]>, <[decpt]>, <[sgn]>);
        char *ecvtf(<[val]>, <[chars]>, <[decpt]>, <[sgn]>);
        float <[val]>;
        float <[val]>;
        int <[chars]>;
        int <[chars]>;
        int *<[decpt]>;
        int *<[decpt]>;
        int *<[sgn]>;
        int *<[sgn]>;
 
 
        char *fcvt(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>);
        char *fcvt(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>);
        double <[val]>;
        double <[val]>;
        int <[decimals]>;
        int <[decimals]>;
        int *<[decpt]>;
        int *<[decpt]>;
        int *<[sgn]>;
        int *<[sgn]>;
        char *fcvtf(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>);
        char *fcvtf(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>);
        float <[val]>;
        float <[val]>;
        int <[decimals]>;
        int <[decimals]>;
        int *<[decpt]>;
        int *<[decpt]>;
        int *<[sgn]>;
        int *<[sgn]>;
 
 
DESCRIPTION
DESCRIPTION
<<ecvt>> and <<fcvt>> produce (null-terminated) strings of digits
<<ecvt>> and <<fcvt>> produce (null-terminated) strings of digits
representating the <<double>> number <[val]>.
representating the <<double>> number <[val]>.
<<ecvtf>> and <<fcvtf>> produce the corresponding character
<<ecvtf>> and <<fcvtf>> produce the corresponding character
representations of <<float>> numbers.
representations of <<float>> numbers.
 
 
(The <<stdlib>> functions <<ecvtbuf>> and <<fcvtbuf>> are reentrant
(The <<stdlib>> functions <<ecvtbuf>> and <<fcvtbuf>> are reentrant
versions of <<ecvt>> and <<fcvt>>.)
versions of <<ecvt>> and <<fcvt>>.)
 
 
The only difference between <<ecvt>> and <<fcvt>> is the
The only difference between <<ecvt>> and <<fcvt>> is the
interpretation of the second argument (<[chars]> or <[decimals]>).
interpretation of the second argument (<[chars]> or <[decimals]>).
For <<ecvt>>, the second argument <[chars]> specifies the total number
For <<ecvt>>, the second argument <[chars]> specifies the total number
of characters to write (which is also the number of significant digits
of characters to write (which is also the number of significant digits
in the formatted string, since these two functions write only digits).
in the formatted string, since these two functions write only digits).
For <<fcvt>>, the second argument <[decimals]> specifies the number of
For <<fcvt>>, the second argument <[decimals]> specifies the number of
characters to write after the decimal point; all digits for the integer
characters to write after the decimal point; all digits for the integer
part of <[val]> are always included.
part of <[val]> are always included.
 
 
Since <<ecvt>> and <<fcvt>> write only digits in the output string,
Since <<ecvt>> and <<fcvt>> write only digits in the output string,
they record the location of the decimal point in <<*<[decpt]>>>, and
they record the location of the decimal point in <<*<[decpt]>>>, and
the sign of the number in <<*<[sgn]>>>.  After formatting a number,
the sign of the number in <<*<[sgn]>>>.  After formatting a number,
<<*<[decpt]>>> contains the number of digits to the left of the
<<*<[decpt]>>> contains the number of digits to the left of the
decimal point.  <<*<[sgn]>>> contains <<0>> if the number is positive,
decimal point.  <<*<[sgn]>>> contains <<0>> if the number is positive,
and <<1>> if it is negative.
and <<1>> if it is negative.
 
 
RETURNS
RETURNS
All four functions return a pointer to the new string containing a
All four functions return a pointer to the new string containing a
character representation of <[val]>.
character representation of <[val]>.
 
 
PORTABILITY
PORTABILITY
None of these functions are ANSI C.
None of these functions are ANSI C.
 
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
 
 
NEWPAGE
NEWPAGE
FUNCTION
FUNCTION
<<gvcvt>>, <<gcvtf>>---format double or float as string
<<gvcvt>>, <<gcvtf>>---format double or float as string
 
 
INDEX
INDEX
        gcvt
        gcvt
INDEX
INDEX
        gcvtf
        gcvtf
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
 
 
        char *gcvt(double <[val]>, int <[precision]>, char *<[buf]>);
        char *gcvt(double <[val]>, int <[precision]>, char *<[buf]>);
        char *gcvtf(float <[val]>, int <[precision]>, char *<[buf]>);
        char *gcvtf(float <[val]>, int <[precision]>, char *<[buf]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
 
 
        char *gcvt(<[val]>, <[precision]>, <[buf]>);
        char *gcvt(<[val]>, <[precision]>, <[buf]>);
        double <[val]>;
        double <[val]>;
        int <[precision]>;
        int <[precision]>;
        char *<[buf]>;
        char *<[buf]>;
        char *gcvtf(<[val]>, <[precision]>, <[buf]>);
        char *gcvtf(<[val]>, <[precision]>, <[buf]>);
        float <[val]>;
        float <[val]>;
        int <[precision]>;
        int <[precision]>;
        char *<[buf]>;
        char *<[buf]>;
 
 
DESCRIPTION
DESCRIPTION
<<gcvt>> writes a fully formatted number as a null-terminated
<<gcvt>> writes a fully formatted number as a null-terminated
string in the buffer <<*<[buf]>>>.  <<gdvtf>> produces corresponding
string in the buffer <<*<[buf]>>>.  <<gdvtf>> produces corresponding
character representations of <<float>> numbers.
character representations of <<float>> numbers.
 
 
<<gcvt>> uses the same rules as the <<printf>> format
<<gcvt>> uses the same rules as the <<printf>> format
`<<%.<[precision]>g>>'---only negative values are signed (with
`<<%.<[precision]>g>>'---only negative values are signed (with
`<<->>'), and either exponential or ordinary decimal-fraction format
`<<->>'), and either exponential or ordinary decimal-fraction format
is chosen depending on the number of significant digits (specified by
is chosen depending on the number of significant digits (specified by
<[precision]>).
<[precision]>).
 
 
RETURNS
RETURNS
The result is a pointer to the formatted representation of <[val]>
The result is a pointer to the formatted representation of <[val]>
(the same as the argument <[buf]>).
(the same as the argument <[buf]>).
 
 
PORTABILITY
PORTABILITY
Neither function is ANSI C.
Neither function is ANSI C.
 
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
*/
 
 
#include <_ansi.h>
#include <_ansi.h>
#include <reent.h>
#include <reent.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include "local.h"
#include "local.h"
 
 
char *
char *
_DEFUN (fcvt, (d, ndigit, decpt, sign),
_DEFUN (fcvt, (d, ndigit, decpt, sign),
        double d _AND
        double d _AND
        int ndigit _AND
        int ndigit _AND
        int *decpt _AND
        int *decpt _AND
        int *sign)
        int *sign)
{
{
  return fcvtbuf (d, ndigit, decpt, sign, NULL);
  return fcvtbuf (d, ndigit, decpt, sign, NULL);
}
}
 
 
char *
char *
_DEFUN (fcvtf, (d, ndigit, decpt, sign),
_DEFUN (fcvtf, (d, ndigit, decpt, sign),
        float d _AND
        float d _AND
        int ndigit _AND
        int ndigit _AND
        int *decpt _AND
        int *decpt _AND
        int *sign)
        int *sign)
{
{
  return fcvt ((float) d, ndigit, decpt, sign);
  return fcvt ((float) d, ndigit, decpt, sign);
}
}
 
 
 
 
char *
char *
_DEFUN (gcvtf, (d, ndigit, buf),
_DEFUN (gcvtf, (d, ndigit, buf),
        float d _AND
        float d _AND
        int ndigit _AND
        int ndigit _AND
        char *buf)
        char *buf)
{
{
  double asd = d;
  double asd = d;
  return gcvt (asd, ndigit, buf);
  return gcvt (asd, ndigit, buf);
}
}
 
 
 
 
char *
char *
_DEFUN (ecvt, (d, ndigit, decpt, sign),
_DEFUN (ecvt, (d, ndigit, decpt, sign),
        double d _AND
        double d _AND
        int ndigit _AND
        int ndigit _AND
        int *decpt _AND
        int *decpt _AND
        int *sign)
        int *sign)
{
{
  return ecvtbuf (d, ndigit, decpt, sign, NULL);
  return ecvtbuf (d, ndigit, decpt, sign, NULL);
}
}
 
 
char *
char *
_DEFUN (ecvtf, (d, ndigit, decpt, sign),
_DEFUN (ecvtf, (d, ndigit, decpt, sign),
        float d _AND
        float d _AND
        int ndigit _AND
        int ndigit _AND
        int *decpt _AND
        int *decpt _AND
        int *sign)
        int *sign)
{
{
  return ecvt ((double) d, ndigit, decpt, sign);
  return ecvt ((double) d, ndigit, decpt, sign);
}
}
 
 
 
 
char *
char *
_DEFUN (gcvt, (d, ndigit, buf),
_DEFUN (gcvt, (d, ndigit, buf),
        double d _AND
        double d _AND
        int ndigit _AND
        int ndigit _AND
        char *buf)
        char *buf)
{
{
  char *tbuf = buf;
  char *tbuf = buf;
  if (d < 0) {
  if (d < 0) {
    *buf = '-';
    *buf = '-';
    buf++;
    buf++;
    ndigit--;
    ndigit--;
  }
  }
  return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);
  return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.