Alan Gonzalez
Alan Gonzalez

Reputation: 43

Updated alpha property value in Inspector to different value - Xcode Swift

I setup my UILabel alpha property to 0.65 using Attributes Inspector but after compiling it is 0.64999976158142 anybody knows why ?

Have seen sometimes constraints, width or height values do the same going from something like 24 to 23.5. enter image description here

Upvotes: 0

Views: 66

Answers (1)

ingAlioth
ingAlioth

Reputation: 59

Computers use a format, binary floating-point, that cannot accurately represent a number like 0.65.

Probably, when the code is compiled, your “0.65” is already rounded to the nearest number in that format, which results in a small rounding error.

Upvotes: 2

Related Questions