x


Rounding to multiples of 0.5

Are there any built-in functions for custom rounding based on multiples? i.e., round to multiples of 0.5?

more ▼

asked Jan 25 '12 at 11:55 PM

ina gravatar image

ina
3.3k 492 551 603

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

If you want to round to the nearest 1/x, where x is a positive integer.

float roundedValue = Mathf.Floor(initialValue * x) / x;
more ▼

answered Jan 26 '12 at 12:08 AM

kevork gravatar image

kevork
415 1 2 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x212
x97
x23
x19

asked: Jan 25 '12 at 11:55 PM

Seen: 829 times

Last Updated: Jan 26 '12 at 04:39 AM