PDA

View Full Version : integers in matlab


gerben
Sep14-04, 07:52 PM
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

enigma
Sep14-04, 08:00 PM
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.