x


90 degrees isnt?

if i type in a rotation of 90 and click off the object, most of the time if i reselect the object it will be either 90.00001 or 89.9999999

  • why cant it just be 90?
more ▼

asked Jul 19 '10 at 11:20 AM

bruno martelli gravatar image

bruno martelli
135 10 13 24

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

2 answers: sort voted first

Due to floating point numbers imprecision, 90 isnt always going to exactly equal 90 when converted into a float.

If you are having trouble comparing them you can use Mathf.Approximately(a, b) to compare them to see if they are ALMOST the same.

more ▼

answered Jul 19 '10 at 11:31 AM

pyro gravatar image

pyro
760 4 5 23

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

When you type into the inspector, it changes a quaternion internally via the euler angles you provide

That means that your three numbers get turned into a 4 number object, and then when they're read back, it's giving you as accurate as a float can represent for the object

Basically: it is 90, but float precision isn't accurate enough to keep it exactly there, so you shouldn't worry about it - you'll never notice it

more ▼

answered Jul 19 '10 at 11:28 AM

Mike 3 gravatar image

Mike 3
30.5k 10 65 252

(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:

x2158
x286
x38
x28

asked: Jul 19 '10 at 11:20 AM

Seen: 945 times

Last Updated: Jul 18 '11 at 09:55 PM