MATLAB interprets all numeric literals as double precision floating point. The problem isn't with the conversion to a string but rather with the fact that when converted into memory the value 180814132242864695
becomes the nearest value which can be represented with 64-bit floating point precision which is consequently 180814132242864704
.
Generally speaking, if you're working with numbers which require more than 52 bits of precision to represent (for example integers larger than 2^53 - 1 = 9007199254740991 ~ 9e15
) you're going to start running into precision issues.
Example:
>> 9007199254740992 == 9007199254740993
ans =
logical
1
The answer linked by Luis Mendo Why is 24.0000 not equal to 24.0000 in MATLAB? gives a more detailed description of the floating point representation used by MATLAB (and most languages).