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

1 次查看(过去 30 天)
Baris Can Ayvaz
Baris Can Ayvaz2018-3-15
回答: Star Strider ,2018-3-15
How can I write a program that indicates a number if it is integer or not?

回答(3 个)

James Tursa
James Tursa 2018-3-15
doc floor
doc ceil
doc round
What happens if you use one of these functions and compare the result to the original value?


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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by