How does round work?

3 ビュー (過去 30 日間)
Tyler Murray
Tyler Murray 2016 年 11 月 10 日
回答済み: Walter Roberson 2016 年 11 月 10 日
I was trying to figure out how the function round worked. I know the format and everything, I am talking about the actual source code. I tried typing in EDIT round but only instructions came up. The only thing that I can think of is if you have a number like 3.14 you would have to convert that number to a string to determine what character the decimal point is at. From there you can take the number to the right and continue with the appropriate rounding. I just don't understand how MATLAB determines where the decimal is located. Any guesses?

回答 (2 件)

Steven Lord
Steven Lord 2016 年 11 月 10 日
We do not distribute the source code for the built-in round function. If you want to see it you will need to start here.
You may be interested in the general procedures described on Wikipedia.
  1 件のコメント
Tyler Murray
Tyler Murray 2016 年 11 月 10 日
I'm not asking for a source code, I am just asking people how they think it is programmed. Just curious.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2016 年 11 月 10 日
Hardware instructions. For example,

Community Treasure Hunt

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

Start Hunting!

Translated by