Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Integers in matlab

  1. Sep 14, 2004 #1
    Does anyone have an idea why this expression in Matlab with integers does not give zero as an answer:

    >> 1019 / 250 * 250 - 1019
    ans = -1.1369e-013
     
  2. jcsd
  3. Sep 14, 2004 #2

    enigma

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    AFAIK, matlab doesn't specifically store an integer variable type.

    If you need to be sure you have an integer output, use either:

    fix(input)

    or

    floor(input)

    to round it to the nearest or down to the next lowest integer.

    Functions such as int2str automatically have a fix() in the command definition.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Integers in matlab
Loading...