AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
atof (String str) yoix.string
 
Returns the number obtained by converting str to a double. atof skips leading white space and then accepts an optional sign, a string of digits that may include a decimal point, and an optional signed integer exponent introduced by an e or E. atof stops at the first unrecognized character and returns 0 when no number is found. atof also accepts the (currently case-sensitive) strings NaN and Infinity, which can be preceded by an optional sign, and converts them to NaN, POSITIVE_INFINITY, or NEGATIVE_INFINITY, which are constants defined in yoix.math.
 
 Example:   Put the simple option parsing program
import yoix.*.*;

double  mag = 1.0;
Option  opt;
int     ch;

while ((ch = getopt(opt, global.argv, "m:")) != -1) {
    switch (ch) {
        case 'm':
            mag = atof(opt.optarg);
            break;

        case '?':
            fprintf(stderr, "Error: %s\n", opt.opterror);
            exit(1);
    }
}

printf("mag=%.1f\n", mag);
in a file named atof.yx, run the interpreter by typing,
yoix atof.yx -m12.3
and
mag=12.3
prints on standard output.
 
 Return:   double
 
 See Also:   atoi, strtod, strton

 

Yoix is a registered trademark of AT&T Inc.