roundto delphi



Delphi roundto

Автор ToLik задал вопрос в разделе Компьютеры, Связь

Вопрос программистам и получил лучший ответ

Ответ от Spider[гуру]
Rounds a floating-point value to a specified digit or power of ten using “Banker’s rounding”.
Unit
Math
Category
Arithmetic routines
Delphi syntax:
type TRoundToRange = -37..37;
function RoundTo(const AValue: Double; const ADigit: TRoundToRange): Double;
C++ syntax:
typedef Word TRoundToRange;
extern PACKAGE double __fastcall RoundTo(const double AValue, const TRoundToRange ADigit);
Description
Call RoundTo to round AValue to a specified power of ten.
AValue is the value to round.
ADigit indicates the power of ten to which you want AValue rounded. It can be any value from –37 to 37 (inclusive).
RoundTo uses “Banker’s Rounding” to determine how to round values that are exactly midway between the two values that have the desired number of significant digits. This method rounds to an even number in the case that AValue is not nearer to either value.
The following examples illustrate the use of RoundTo:
ExpressionValue
RoundTo(1234567, 3)1234000
RoundTo(1.234, -2)1.23
RoundTo(1.235, -2)1.24
RoundTo(1.245, -2)1.24
Note:The behavior of RoundTo can be affected by the Set8087CW procedure or SetRoundMode function.
Вообще, на будущее, работай со справкой, а то программы пишешь, а справкой пользоваться не умеешь...
Источник: Delphi Help

Ответ от Марьян[активный]
Задай соответствующий тип переменной, которую собираешься "округлить"

Ответ от 22 ответа[гуру]
Привет! Вот подборка тем с похожими вопросами и ответами на Ваш вопрос: Вопрос программистам
 

Ответить на вопрос:

Имя*

E-mail:*

Текст ответа:*
Проверочный код(введите 22):*