## Good Will Hunting

Many viewers of the movie were so taken by Matt Damon that they never realized that he knows no physics whatsoever. The painful reality of this was finally revealed at a recent press junket when a bitter physics professor named Dr. Peter Plachta asked Damon to convert a number to scientific notation (apparently Dr. Plachta was incredulous when he realized that somebody in the physics world was more popular than he was). So anyway, when Damon was unable to answer the question, his agent began damage control by hiring a team of programmers to write him a program that would do this conversion for him.

You will need to convert a real (floating point) number to scientific notation, i.e. a number of the form x.yzw*10p, where the digit x is non zero, the digits y, z, w are possibly zero, and p is a non-zero integer. If p is zero, simply output x.yzw. Therefore, the number 1234.0 is 1.234 x 103 in scientific notation. However, since superscript is a little tough to do in a text based system, the above answer would be outputted as follows: `1.234 x 10^3` (note that there is ONE space before and after "x" and no other spaces elsewhere) All numbers should be rounded to 3 decimal places. The number '0' denotes the end of data.

### Input

A series of test cases, terminated by the number 0.

### Output

For each test case, output the number in properly formatted scientific notation.

### Sample Input

```1234.56
1.2
0.098
0
```

### Sample Output

```1.235 x 10^3
1.200
9.800 x 10^-2
```

Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M
Added: Sep 29, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

• (0/0)

• (0/0)
The TLE is correct. Your first nested loop legitimately never terminates with the input.

• (0/0)
Bazinga! Darn X.X

• (0/0)
It keeps saying

"Test Case #1: Runtime Error (Invalid floating point operation)"

what am I doing wrong?

• (1/0)
Have you taken into consideration negative numbers?

• (0/0)
Thanks, i'll look into it.

• (0/2)
About time you finished this program

• (2/2)
i mistook the x as the multiplication sign
held me back 1 hour of test driving

• (1/1)
its something stupid i left out. it has to be. ive checked it millions of millions of times on turbo pascal 7.

• (1/0)
Your program doesn't work for the sample input
(Look at your output and their output VERY closely)

• (1/3)
can there be negative cases?

• (1/0)
read the comments below

• (0/0)

• (1/0)
There are no such cases in the input.

• (1/0)
What is the definition of double/float?

Think about it.

• (1/0)
KK sorry, stupid question

• (1/0)
For some of my decimal numbers I get .#INF. Do any of you know what I could do to fix this?

• (1/0)
#INF is what C++ prints out when you attempt to print infinity. I explained during my lesson on the representation of data types in memory that floating point variables can hold certain "special" values such as infinities, NaNs, and denormal numbers.

Evidently, you either multiplied by 10 too many times, or divided by zero.

• (0/2)
lol gnanu we just robbed jacob of 10 points each at almost the same time

• (1/1)
Luckily, Gnanu didn't take my bet. But yeah, you still get 10 pts off me :S

• (1/0)
Does this include negative numbers?

• (1/0)

• (1/0)
should normal physics rules be followed when rounding a 5? (round up if previous is odd and down if even)

• (1/0)
I imagine that using setprecision or printf gives you the correct output.