[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NaN error
From: |
Francesco Potortì |
Subject: |
Re: NaN error |
Date: |
Tue, 11 Jan 2011 19:42:58 +0100 |
>I came across the 196 algorithm at:
>http://mathworld.wolfram.com/196-Algorithm.html
>
>I decided to code a version of it, and it works... until I increase the
>iterations past a limit. I think the error is in the memory, but I'm
>just not sure where the error is.
>
>function [ a ] = rev (a,iter)
>
>
>for k=1:iter
>
>a=num2str(a);
>b=[];
>
>for i=length(a):-1:1
>j=length(a)-i+1;
>b(j)=a(i);
>endfor
>
>b=str2double(b);
>a=str2double(a);
>
>a=b+a;
>
>endfor
>endfunction
>
>The results I get are:
>octave-3.2.3> rev(123,1)
>ans = 444
>octave-3.2.3> rev(123,10)
>ans = 1354353
>octave-3.2.3> rev(123,11)
>ans = NaN
octave> num2str(1354353)
ans = 1.35435e+06
--
Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa Email: address@hidden
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/
- NaN error, Los Griegos Engineering, 2011/01/11
- Re: NaN error,
Francesco Potortì <=
- NaN error, John W. Eaton, 2011/01/11