```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: floating point help!
Date: Thu, 24 Jun 2010 18:38:05 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 23
Message-ID: <i008md\$i18\$1@fred.mathworks.com>
References: <hvvbvn\$lim\$1@fred.mathworks.com> <1675532262.20705.1277390646666.JavaMail.root@gallium.mathforum.org>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1277404685 18472 172.30.248.37 (24 Jun 2010 18:38:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 24 Jun 2010 18:38:05 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:647840

bogfrog <aj00mcgraw@gmail.com> wrote in message <1675532262.20705.1277390646666.JavaMail.root@gallium.mathforum.org>...
> >digits = double(sprintf('%d', 3813919) - '0');
>
> This works beautifully, but what in the world is going on?
>
> How does subtracting '0' turn this into an array of digits?

a hint:
- the DOUBLE typecast is not neccessary

d=sprintf('%d',1357)-'0'     % <- or -48, ie, ASCII rep of CHAR '0'
%    d = 1     3     5     7
% and the rather trivial trick behind it...
c=sprintf('%d',8)
%    c = 8
% -or- its ASCII rep
a=sprintf('%d - %d',c,'0')
%    a = 56 - 48
% thus,
56-48
%    ans = 8

us
```