hello again!!
my problem this time is not programming problem ( i think it is Boolean one )
i create a tab button and tab control without any problem but when i resize it i do two value
0.5 and 0.500 , but imagine what happen
if i use 0.5 i get very small size in other hand i use 0.500 i get big size
and you know that in math 0.5 == 0.50000000000000 ( even how zero that i have )
any help !!
0.5 != 0.5000000000 ??? why ??
Moderators: CEGUI MVP, CEGUI Team
Re: 0.5 != 0.5000000000 ??? why ??
This does not make any sense. Please provide the relevant code and screenshots.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!
Re: 0.5 != 0.5000000000 ??? why ??
belkacem wrote:hello again!!
and you know that in math 0.5 == 0.50000000000000 ( even how zero that i have )
Unfortunately, for computer floating points this is not true. Basically, you never compare floats or doubles for equality (with ==), that will result in bugs, always compare the difference of two floats against a comparison criterion (usually called "epsilon"), as in
Code: Select all
const float epsilon = 0.000001f;
float a = 100.f;
float b = 50.f;
//wrong!: if (a - b == 50.f) doStuff();
if (a - b < epsilon) doStuff(); // correct
Note that this is beginner's programmers knowledge and you should already have been aware of it. It may or may not have anything to do with your widget sizing problem.
Re: 0.5 != 0.5000000000 ??? why ??
Mikademus wrote:Code: Select all
if (a - b < epsilon) doStuff(); // correct
should be:
Code: Select all
if (std::fabs(a - b) < epsilon) doStuff(); // correct
And you can use std::numeric_limits<float>::epsilon() as epsilon.
Still, I think this could be a parsing problem, not necessarily a floating point precision problem.
Re: 0.5 != 0.5000000000 ??? why ??
i create a tab button and tab control without any problem, but when i resize it i do two value 0.5 and 0.500, but imagine what happen: if i use 0.5 i get very small size, in other hand i use 0.500 i get big size.
I am pretty sure he is not talking about comparing two floats, despite the title of this thread. This is why I asked for more info
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!
Who is online
Users browsing this forum: Google [Bot] and 3 guests