Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Sprite Stick To Mouse Cursor
ROLLOVER FADES
Pass handler to next Sprite
Get Crazy
Volume Control-Slider
Can't get picture from field - Valentina
Change ShapeType of a Shape cast member
Library dmm_cdext - Audio CD Controller
Yes/No Alert
Find out which cast members use a given font
 

 

 

Behavior Round floating point numbers off to nearest ten

Added on 11/8/2005

 

Compatibilities:

This item has not yet been rated

Author: psykopath (website)

Round off floating point numbers to the nearest ten. Does not work with integers

on roundOff num
  tempFP = the floatPrecision
  numString = string(num)
  --put "original number:"&&numString
  repeat with i = 0 to tempFP
    tot = numString.char.count
    --put "deleting char:"&&numString.char[tot]
    delete char tot of numString
  end repeat
  tot = numString.char.count
  dependent = numString.char[tot]
  --put "dependent is:"&&dependent
  dependent = integer(dependent)
  if dependent>=5 then
    dif = 10-dependent
    myNum = integer(numString)+dif
  else
    myNum = integer(numString)-dependent
  end if
  return myNum
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail