PHP Classes

Scientific notation 'E'

Recommend this page to a friend!

      Eval Math  >  All threads  >  Scientific notation 'E'  >  (Un) Subscribe thread alerts  
Subject:Scientific notation 'E'
Summary:notify some bug
Author:Banphot Nuchleang
Date:2010-05-31 03:56:38
Update:2011-10-27 12:14:50

  1. Scientific notation 'E'   Reply   Report abuse  
Banphot Nuchleang - 2010-05-31 03:56:38
I got a bug about scientific notation. Numeral variables sometimes output in the 'E' notation which conflicts 'e' constant since the variable name and its index are case-insensitive.

For example, a variable has value 1.234567E-15. When piping the variable into expression, the class evaluates it as (1.234567 x exp(1)) - 15 instead of 1.234567 x (10^-15).

I solve this by modifying your 'e' constant into 'ee' that works for me.

  2. Re: Scientific notation 'E'   Reply   Report abuse  
Bueno - 2011-10-27 12:14:51 - In reply to message 1 from Banphot Nuchleang
you can simply modify expression in nfx method:

- $ex = preg_match('/^([a-z][a-z0-9]*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr($expr, $index), $match);

+ $ex = preg_match('/^([a-z][a-z0-9]*\(?|\d+(?:\.\d*)?(?:(e[+-]?)\d*)?|\.\d+|\()/', substr($expr, $index), $match);