Question: I have one correctly initialized AutoNumeric.js instance on a page ("ok" alert)

```
<input type="text" id="id1" value="23332" data-money="true" />

 $("[data-money]").each(function(ndx, lmnt) {
   new AutoNumeric(lmnt, {
     decimalCharacterAlternative: '&',
     unformatOnSubmit: true,
     digitGroupSeparator: ' ',
     minimumValue: 0,
     modifyValueOnWheel: false,
   });
 });

 var lmnt = $('#id1').get(0);
 if (AutoNumeric.test(lmnt)) {
    alert('ok');
 }

```

How can I get an instance to this object by id (to set data and to do other operations)?

Answer: 
> 
> How do I evaluate decimals & floating point numbers in scientific e notation ... (?)
> 
> 
> 

To convert a string into FP value use `strtod()` [@M Oehm](https://stackoverflow.com/questions/46811063/how-do-i-evaluate-decimals-floating-point-numbers-in-scientific-e-notation-e)

---

Yet code has other problems in that the operator symbols `'-'` and `'+'` may also begin valid value tokens like `-123.45`.

```
// insufficient test to determine if the next part of the string is a number or operator.
if(isdigit(ch)) 
  push(ch-'0');

```

Use `strtod()` to convert text to `double` **and** determine if the next part of the string is a `double`.

Alternative code:

```
  const char *st = pofx;
  while (*st) {
    char *end; //location to store end of FP parsing
    double value = strtod(st, &end);
    if (end > st) {
      push(value);
      st = end; 
    } else if (isspace((unsigned char) *st)) {
      st++;
    } else {
      switch (*st) {
        case '+':push(pop() + pop());break; // pop order irrelevant
        case '-':{ double t = pop(); push(pop() - t);break; } // pop order relevant
        case '*':push(pop() * pop());break;
        ...
        default: {
          printf("Input invalid operator: character code %d\n", *st);
          return 0;
        } 
      }  // end switch
      st++;
    }
  }

```

---

Re-write `push()` 

```
void push(double elem) {
  if (top + 1 >= SIZE) {
    printf("Stack overflow\n");
    return;
  }
  s[++top] = elem;
}

```

---

Wrong argument to `fgets()`

```
char pofx[50];
// fgets(pofx,100,stdin); // 100??
fgets(pofx, sizeof pofx, stdin); // better

```
The function `strtod` from `<stdlib.h>` will parse a `double` for you. It takes the string to parse and a pointer to a string, that will begin with the first unparsed character. (There's a similar function for long integers, `strtol`.)

Here's an example of how this might work in your case. (The code just prints out the tokens and doesn't do any calculations.)

```
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

int is_number(const char *p)
{
    if (*p == '-' || *p == '+') p++;
    if (*p == '.') p++;

    return isdigit((unsigned char) *p);
}

int main(void)
{
    const char *line = " .1 20.1* 1.0e-3+2e+7 * -1.0*";
    const char *p = line;

    while (isspace((unsigned char) *p)) p++;

    while (*p) {
        if (is_number(p, after_op)) {
            char *end;
            double x = strtod(p, &end);

            if (p == end) {
                puts("Illegal number");
                p++;
            } else {
                printf("Number %g\n", x);
                p = end;
            }
        } else {
            int c = *p++;

            switch (c) {
            case '+':   puts("Operator add"); break;
            case '-':   puts("Operator sub"); break;
            case '*':   puts("Operator mult"); break;
            case '/':   puts("Operator div"); break;
            case '^':   puts("Operator pow"); break;
            default:    printf("Illegal char '%c'\n", c);
            }
        }

        while (isspace((unsigned char) *p)) p++;
    }

    return 0;
}

```

This is still very crude, mind you. Strings like `20x21` will be parsed as number 20, unknown character `x` and number 21. While this code is bad at detecting and reporting errors (which really should be done, but it's left as an exercise, yadda, yadda), it works for valid input.

[*Edit*: I've incorporated chux's suggestions and also made the code compatible to read numbers with explicit signs, but that means that the binary operators `-` and `+` cannot immediately be followed by a digit. Pick your poison. I've also allowed the abridged version that leaves out a leading zero, e.g. `.12`, a format that I'm not very fond of.]