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 4:12 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message >
> 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

It seems that this rule does not applied for scalar expression affected with colon operator on the lhs. To avoid JIT, I put the argument as parameters of foo function.

function [a rd rs] = foo(b, c, d)

a = zeros(1,2,'double');
bar = b + c -d;
a(1) = b + c -d;
a(2) = bar;

rd = 0;
rd(:) = b + c -d;

rs = single(0);
rs(:) = b + c -d;

end % foo

% and here is the result

>> [a rd rs] = foo(single(1),1e-9,1)

a =

0 0

rd =


rs =



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.