## how to make matlab display full number digits

### Talaria (view profile)

on 6 Aug 2011
Latest activity Edited by Mark Bower

on 20 Oct 2017

### Oleg Komarov (view profile)

how to make matlab output the full number in digits, and not in exponential form?

### Oleg Komarov (view profile)

on 6 Aug 2011

```format long
```

or

```sprintf('%16.f',2332456943534324)
```

### Image Analyst (view profile)

on 7 Aug 2011

"format long" won't do it. See my example. You can use fprintf() to print to the command window (again, see example), or sprintf() to save into a variable or display in the command window if (and save to "ans") if you don't assign a variable to the return value and leave off the semicolon.

```fprintf('\nFirst, using format long...\n');
format long
m = rand(1,3)/1000
fprintf('\nNow, using fprintf()...\n');
fprintf('%.8f ', m)
fprintf('\n\nNow, using sprintf()...\n');
sprintf('%.8f ', m)
```

Results in the command window:

```First, using format long...
```
```m =
1.0e-003 *
```
`   0.549723608291140   0.917193663829810   0.285839018820374`
```Now, using fprintf()...
```
```0.00054972 0.00091719 0.00028584
```
```Now, using sprintf()...
```
```ans =
0.00054972 0.00091719 0.00028584
```

I don't know of anyway to have it operate like you want by default without issuing a command like fprintf().

Walter Roberson

### Walter Roberson (view profile)

on 7 Aug 2011

format long g

helps. However, integers that exceed 2^53 will be represented in scientific notation with "format long g". To get the full digits of those, you need to use sprintf() or fprintf()

Image Analyst

### Image Analyst (view profile)

on 7 Aug 2011

Yes it can help. Sometimes some sneak through even with that (if there would be more than three 0's to the right of the decimal point), like this which I tried:

m =
Columns 1 through 4
0.000538342435260057 0.000996134716626886 7.81755287531837e-005 0.000442678269775446
Columns 5 through 8
0.000106652770180584 0.000961898080855054 4.63422413406744e-006 0.000774910464711502

### Huw S (view profile)

on 31 Jan 2017

If you don't need to know all the decimal points, then do your equation inside round.

saves all the other bother of exponentials.

Walter Roberson

### Walter Roberson (view profile)

on 31 Jan 2017

Unfortunately not the case:

```>> format short
>> round(2^54)
ans =
1.8014e+16
>> format long g
>> round(2^54)
ans =
1.8014398509482e+16
>> uint64(2^54)
ans =
uint64
18014398509481984
```

### Mark Bower (view profile)

on 20 Oct 2017
Edited by Mark Bower

### Mark Bower (view profile)

on 20 Oct 2017

A nice, consistent solution is to use "num2str()". The same call works for both display from the command line:

```> val = 1234567890
val =
1.234567890000000e+09
> num2str(val)
ans =
1234567890
```

and also within print statements:

```> sprintf(num2str(val))
ans =
1234567890
```

It also works for floating point numbers:

```> val = 123456.789
val =
1.234567890000000e+05
> sprintf(num2str(val))
ans =
123456.789
>
```