plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

fmtstrtod.3 (1285B)


      1 .TH FMTSTRTOD 3
      2 .SH NAME
      3 fmtstrtod, fmtcharstod \ - convert text to numbers
      4 .SH SYNOPSIS
      5 .B #include <utf.h>
      6 .br
      7 .B #include <fmt.h>
      8 .PP
      9 .PP
     10 .B
     11 double	fmtstrtod(char *nptr, char **rptr)
     12 .PP
     13 .B
     14 double	fmtcharstod(int (*f)(void *), void *a)
     15 .SH DESCRIPTION
     16 .I Fmtstrtod
     17 converts a string pointed to by
     18 .I nptr
     19 to floating point representation and, if
     20 .I rptr
     21 is not zero, sets
     22 .I *rptr
     23 to point to the input character immediately after the string converted.
     24 .I Fmtstrtod
     25 recognizes an optional string of tabs and spaces,
     26 then an optional sign, then a string of digits optionally
     27 containing a decimal point, then an optional 
     28 .L e
     29 or
     30 .L E
     31 followed by an optionally signed integer.
     32 .PP
     33 .PP
     34 .I Fmtcharstod
     35 interprets floating point numbers in the manner of
     36 .IR atof ,
     37 but gets successive characters by calling
     38 .BR (*\fIf\fP)(a) .
     39 The last call to
     40 .I f
     41 terminates the scan, so it must have returned a character that
     42 is not a legal continuation of a number.
     43 Therefore, it may be necessary to back up the input stream one character
     44 after calling
     45 .IR fmtcharstod .
     46 .SH SOURCE
     47 .B https://9fans.github.io/plan9port/unix
     48 .SH SEE ALSO
     49 .IR fscanf (3)
     50 .SH DIAGNOSTICS
     51 Zero is returned if the beginning of the input string is not interpretable
     52 as a number; even in this case,
     53 .I rptr
     54 will be updated.