type casts in KLD
Artis Caune
ac-lists at latnet.lv
Tue Feb 24 06:51:52 PST 2004
Hi!
I'm writting kld module, and have some weird problems
with mixing types and casts.
e.x.
"if (long + u_long + u_long < 0)" don't work,
but
"if (long < 0 - u_long - u_long)" works fine!
and code like this:
"cur_rate = min_rate + \
(((max_rate - min_rate) * \
(cur_level / level / 100))) / 100)"
where:
cur_rate, min_rate, max_rate - u_long;
cur_level, level - u_quad_t ;
I cast-ed expresion:
"cur_rate = min_rate + \
(((max_rate - min_rate) * \
((u_long) cur_level / (u_quad_t) level / 100))) /
(u_long) 100)"
and it seems to be ok!
Someone can point me to article, url where
I can find more about complex arithmetic operations
with different types and
how to proper use different types in "if" statements?
--
Artis
More information about the freebsd-hackers
mailing list