PDA

Просмотр полной версии : Убрать цифры после запятой


Neosano
24.10.2006, 17:59
У меня есть переменная с числом от 1 до 20 и мувик с анимацией (20 кадров). Анимация переходит на кадр переменной... но проблема в том что эта переменная не целая, а с дробной частью, поэтому иногда глюки бывают, как это исправить?

etc
24.10.2006, 18:07
А что ты подразмеваешь под глюками?
Вычисления с плавающей запятой никогда не бывают точными.

wvxvw
24.10.2006, 18:12
Math.round, Math.floor, Math.ceil, Math.abs в зависимости от того, что нужно

MrPoma
24.10.2006, 18:13
отбрось дробную часть с помощью Math.floor()

Neosano
24.10.2006, 18:14
я не говорил глюк.. или говорил хех, мне нужно убрать все после запятой, тоесть чтоб не было 2.598 а 2

wvxvw
24.10.2006, 18:16
ты говорил "глюк", а "хех" не говорил.
в твоем случае - Math.floor()

Neosano
24.10.2006, 18:17
эм, поподробнее можно?

wvxvw
24.10.2006, 18:21
да куда уж подробнее...
trace(Math.floor(2.598));

Neosano
24.10.2006, 18:21
в хелпе посмотрел, не понял...

Neosano
24.10.2006, 18:22
тьфу, ну я стормозил, спасибо всем

wvxvw
24.10.2006, 18:26
floor (Math.floor method)
public static floor(x:Number) : Number

Returns the floor of the number or expression specified in the parameter x. The floor is the closest integer that is less than or equal to the specified number or expression.

Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non-emulated math functions that Flash Player 5 supports.

Parameters
x:Number - A number or expression.

Returns
Number - The integer that is both closest to, and less than or equal to, parameter x.

Example
The following code returns a value of 12:

Math.floor(12.5);

The following code returns a value of -7:

Math.floor(-6.5);
floor (англ. "пол") значит, что результатом вычисления будет наименьшее близжайшее к параметру целое число.

MrPoma
24.10.2006, 18:27
gotoAndStop(Math.floor(2.598)) - идет во 2 кадр