MATLAB Answers

0

How can I write a program that indicates a number if it is integer or not?

Asked by Baris Can Ayvaz on 15 Mar 2018
Latest activity Answered by Star Strider
on 15 Mar 2018
How can I write a program that indicates a number if it is integer or not?

  0 Comments

Sign in to comment.

3 Answers

Answer by James Tursa
on 15 Mar 2018

doc floor
doc ceil
doc round
What happens if you use one of these functions and compare the result to the original value?

  0 Comments

Sign in to comment.


Answer by Roger Stafford on 15 Mar 2018
Edited by Roger Stafford on 15 Mar 2018

If n is your number, then
round(n)==n
is true if and only if n is an integer

  0 Comments

Sign in to comment.


Answer by Star Strider
on 15 Mar 2018

Use the rem (link) or mod (linked to in that page) functions.
isint = @(x) rem(x,1) == 0;
It returns a logical result.

  0 Comments

Sign in to comment.