Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
rounding
Old
brunkdaddy
Guest
 
Status:
Posts: n/a
Default rounding - 05-09-2010, 07:56 PM

Hey guys,

I want to round a distance between two objects and have one say it.

I have the object say 'what as a string' (distance)
the only problem is it rounds to a whole number eg 7.0. I have to get it to round to one decimal place eg 7.4.

Any tips?
   
Reply With Quote
Old
Niteshifter
Guest
 
Status:
Posts: n/a
Default 05-10-2010, 04:56 PM

let x be the number in question:

round(x * 10) / 10

You would round the value multiplied by 10, so that you now have the number rounded to one decimal place, next you would put it back to normal by dividing the result by 10.
   
Reply With Quote
Old
brunkdaddy
Guest
 
Status:
Posts: n/a
Default 05-10-2010, 05:53 PM

it didnt work - it still just rounds to whole number.

my code is:

dist2Hole set value to square root of ((xDist * xDist) + (zDist * zDist))
ball say round dist2Hole as a string
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.