MATLAB Answers

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

조회 수: 3(최근 30일)
Baris Can Ayvaz
Baris Can Ayvaz 15 Mar 2018
Answered: Star Strider 15 Mar 2018
How can I write a program that indicates a number if it is integer or not?

  댓글 수: 0

로그인 to comment.

답변 수 (3)

James Tursa
James Tursa 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

로그인 to comment.


Roger Stafford
Roger Stafford 15 Mar 2018
Roger Stafford 님이 편집함. 15 Mar 2018
If n is your number, then
round(n)==n
is true if and only if n is an integer

  댓글 수: 0

로그인 to comment.


Star Strider
Star Strider 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

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by