Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
Software
»
comp.softsys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
Computation precision on command line and in scripts
Replies:
8
Last Post:
Feb 11, 2013 6:59 AM




Re: Computation precision on command line and in scripts
Posted:
Feb 7, 2013 9:39 AM


"Pierre" wrote in message <kf05u8$9n3$1@newscl01ah.mathworks.com>...
> > The underlying question was: Are computations with singles performed in double or in single precision??
This question is interesting but actually is not a right question to ask.
The documentation states that
1) an arithmetic expression is mixed with two numerical type, the result is cast in lower type, then the operation is carried out.
2) The expression is evaluated from left to right
That explains the result like:
>> uint8(1)+(0.4+0.1+0.1+0.1)
ans =
2
>> 0.4+0.1+0.1+0.1+uint8(1)
ans =
2
>>
IMO the observation in your example is not due to casting, but due to JIT accelerator might detect (single(1)  1) is 0. The JIT is activated or not in different mode (command line, function, or debug mode). It also depends on which MATLAB version you are running.
Bruno



