The Math Forum

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.soft-sys.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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 9,822
Registered: 7/26/08
Re: Computation precision on command line and in scripts
Posted: Feb 7, 2013 9:39 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Pierre" wrote in message <kf05u8$9n3$>...

> 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 =


>> 0.4+0.1+0.1+0.1+uint8(1)

ans =



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.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.