Sun 08 Apr 2012 05:03:04 PM UTC, comment #3:
You are right. This seems to be a problem on 64 bit systems. When I used Debian wheezy, 64bit machine I can reproduce this problem.
$ octave -q
warning: mark_as_command is obsolete and will be removed from a future version of Octave
octave:1> num2str(2.4e9,15)
ans = -1894967296
octave:2> version
ans = 3.2.4
octave:3> which num2str
`num2str' is a function from the file /usr/share/octave/3.2.4/m/general/num2str.m
octave:4> sprintf('%d',double(intmax))
ans = 2147483647
octave:5> sprintf('%d',double(intmax)+1)
ans = -2147483648
If I use the same commands on Debian Wheezy, 32 bit machine I get
$octave -q
octave:1> num2str(2.4e9,15)
ans = 2400000000
octave:2> version
ans = 3.2.4
octave:3> which num2str
`num2str' is a function from the file /usr/share/octave/3.2.4/m/general/num2str.m
octave:4> sprintf('%d',double(intmax))
ans = 2147483647
octave:5> sprintf('%d',double(intmax)+1)
ans = 2147483648
|