> > >I have a question. How would you move the decimal left or right,
> > depending on if the
> > >number a user enters is negative or not, and then move it that many
> > spaces? If
> > >needed, it would add zeros.
> > Hmm. Trying to remember what grade I learned this in. You multiply by 10
> > to move it right, divide by 10 to move it left.
> The way we were just now taught (I'm in 7th grade Pre-Algebra) was using
> exponets. To move it to the right, we take 10 to the so and so power. To
> left we do 10 to the negative power of so and so. So...I just answered my
> own question... Im go to assume that will work as well. But one part is
> still unanswered:
So we are helping you do your homework?
> > >One other question. How would I find the first 0 of a repeating zero.
> > Like 204,000.
> > >How would you find the 0 in the 4th column.
> > Treat it as a string and look for the first set of double zeros.
> Yes... I could do this... But what if the number is 2.5000435000 or
And what do you want to do if that's the number?
> What I need to do is this. The user specifies a number, let's say 0.0046.
> What the script needs to do, is take that number, and print it out in
> scientific notation. So the answer for 0.0046 would be 4.6 x 10 ^-3. From
> notes it says:
> All numbers expressed in scientific notation are given as the product
> a number between 1 and 10 and a power of 10.
Well, a couple ways you could do it. You could multiply/divide the number by
10 until it's between 1 and 10, keeping track of how many times you
multiplied/divided and that'll be your exponent.
So 0.0046 would be multiplied by 10 three times to get 4.6 and you'd turn
your 3 into 10^-3, resulting in 4.6x10^-3.
240000.00 would be divided by 10 five times to get 2.4 * 10^5
Or you could use some regular expressions or regular string expressions to
find the length of the number, trucate it to how ever many digits you want
and find out what your exponent is.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php