MI Sabic - 1 year ago 96

Java Question

I want to show factorial of a number in scientific notation.

For example -

`100! = "9.332621544e+157"`

Is there any other way to do this besides

`NumberFormat`

`BigDecimal res=new BigDecimal("1");`

for(int i=2;i<=x;i++){

res=res.multiply(BigDecimal.valueOf(i));

}

str=String.valueOf(res+"");

display.setText(str);

I'm really sorry if this question is vague to understand. Any help would be appreciated. Thanks in advance.

Answer Source

Not nice but changing

```
str=String.valueOf(res+"");
```

to

```
String str=res.doubleValue()+"";
```

will do the job