PHP division operator outputing letters and hyphens

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ballinonabudget
Forum Newbie
Posts: 8
Joined: Wed May 27, 2009 6:32 pm

PHP division operator outputing letters and hyphens

Post by ballinonabudget »

Hi. Please help! for some reason my mathematical operation below is outputting an "E" and a "-" at the end. I tried to debug by omitting the
division part from the end and I got no letters or dashes. Not sure why the division bit is causing this output. Any thoughts?

This is the output for $timeDelay : 1.2256517540567E-8

Code: Select all

$_SESSION['timeDelay'] = sqrt($dielectricConstant) * $length / 3000000000;
$timeDelay = $_SESSION['timeDelay'];
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: PHP division operator outputing letters and hyphens

Post by flying_circus »

Isn't that just scientific notation for 8 trailing zero's?
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PHP division operator outputing letters and hyphens

Post by Eric! »

You're working with dielectric constants and the speed of light, but you don't know this number format?

1.2256517540567E-8 = 0.000000012265...


or 12.2565 nano seconds (ns)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP division operator outputing letters and hyphens

Post by VladSun »

Eric! wrote:You're working with dielectric constants and the speed of light, but you don't know this number format?
Frankly, it's more often used in IT and CS than in other engineer sciences.

It's the normalized value of 0.000000012256517540567 :

1.2256517540567 * 10^(-8)

Or

XXXE-YY = XXX * 10^(-YY)

XXXE+YY = XXX * 10^(+YY)

Try using
http://bg.php.net/number_format
There are 10 types of people in this world, those who understand binary and those who don't
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PHP division operator outputing letters and hyphens

Post by Eric! »

VladSun wrote:Frankly, it's more often used in IT and CS than in other engineer sciences.
Being an electrical engineer, I can tell you it is pretty common in my field. I use dielectric constants too, especially for high frequency work and antenna design. It is also used in physics and mechanical enginering a lot. In fact most calculators default to allowing xxxEyy notation for entry.
Post Reply