return the numerator and denimentor
2 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone
Is there such a way to return the numerator and the denomenator of a given rational number
for example x = 1/2
I want to get n=1 , d=2
0 件のコメント
採用された回答
John D'Errico
2019 年 12 月 9 日
Rat gives rational results for a floating point number, sometimes they are only approximate, of course.
[n,d] = rat(1/2)
n =
1
d =
2
[n,d] = rat(pi)
n =
355
d =
113
参考
カテゴリ
Help Center および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!