Re: weird problem
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 27 Jan 2007 13:41:43 GMT
Alef.Veld@xxxxxxxxx wrote:
| while (search != NULL) {
|
| if (collisions>0 &&
| collisions ==((grid_size - grid_start) * (grid_size -
| grid_start)))
I already told you that the comparison between an integer and a float
value for equality is rather likely not to work - you have to round
the result of the floating point calculation to the nearest integer
before you can do a meaningful comparison.
I'm going to use decimals. But maybe not testing for equality, but
would it not be possible to do 1 > 00000000.2 for example ?
Comparing for being larger or smaller is no problem but testing for
equality is. If you have e.g. something like
float a = 1.0;
a = ( a / 3.0 ) * 3.0;
if ( a == 1 )
may already fail since floating floating point calculations can only
done with a limited precision and that results in rounding errors.
And for that reason the result of first dividing 1.0 by 3.0 and after-
wards multiplying by 3.0 may be e.g. 0.99999999999 instead of 1.0, so
the test for equality with 1 (or 1.0) would fail.
And now concerining the 'sizeof(float) + 7' thingI did not know that. I have snprintf so that should work fine.
Just having snprintf() is not necessarily enough - there are
some implementations (notably on Windows, at least according
to some discussion here a few days ago, but also older libc
versions) that don't work as they are supposed according to
the C99 standard. So before you decide to use that method you
better write a small test program to check if your snprintf()
does it "correctly".
PS: Please be so kind to follow the convention normally used in
technical newsgroups and don't top-post.
Personally i don't mind to read top-posts, i just scroll from up to
down instead of the other way around. Besides, i usually want to
know the answer instead of the question so this save me alot of time.
If i think the answer is interesting, i back up. I think the whole
top-posting thing is getting way out of hand. As long as a post is
readable and not written by a 5 year old, it should be ok by my
standards.
Well, I find top-posting a PITA - I need the question to understand
what the answer is for and with top-posting I can only guess at best,
especially if this isn't just a single question with a single answer.
It's like hearing a recorded conversation but with what the parti-
cipants said all re-ordered in a more or less random way (or at least
with what was said last being replayed first). And many regulars,
especially of technical newsgroups, seem to feel the same way. Of
course, nobody can force you not to top-post, bu then you can't force
the very people that may be able to answer your question not to dis-
regard or even plonk you. Pick your choice;-)
I also personally get quite agitated by people pushing down their
usenet etiquette down my throat
If you get agitated that easily then you should consider if news-
groups are a healthy place for you to be;-) And did you consider
that usenet etiquette wasn't made up just on a whim to "push down
the throats" of unsuspecting newbies but may be the result of some
twenty years of experiences with usenet?
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- Follow-Ups:
- Re: weird problem
- From: Alef . Veld
- Re: weird problem
- References:
- weird problem
- From: atv
- Re: weird problem
- From: Jens Thoms Toerring
- Re: weird problem
- From: Alef . Veld
- Re: weird problem
- From: Jens Thoms Toerring
- Re: weird problem
- From: Alef . Veld
- Re: weird problem
- From: Jens Thoms Toerring
- Re: weird problem
- From: Alef . Veld
- Re: weird problem
- From: Jens Thoms Toerring
- Re: weird problem
- From: Alef . Veld
- weird problem
- Prev by Date: Re: qsort wiht struct and pointers - GAL
- Next by Date: Re: Criticisms?
- Previous by thread: Re: weird problem
- Next by thread: Re: weird problem
- Index(es):
Relevant Pages
|