Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiler Warnings 3

Status
Not open for further replies.

WayneRyan

Programmer
May 23, 2002
202
US
Hi there,

Normally I post in the Access forums, but now
I have a VC application that I'll be working
with for a few days.

What I'm trying to do is get rid of some
compiler warnings, the app runs fine but
must get rid of warnings.

temp = pri_scale_factor * ...

temp is an int
pri_scale_factor is a float

C4244, conversion from float to int, possible
loss of data.

I resist changing the datatype of temp, if it
was dealing with strictly integers, I think a
union could help.

Any ideas?

Thanks
Wayne
 
Hi Wayne,

Use a type-cast: temp = (int)( pri_scale_factor * ... );
OR: use /W2 or /W1 compiler option.
Marcel
 
dont use the union of an int and a float... it will not produce the desired results. You could just cast the value as an int to avoid the message, you can disable it if you dont care, if you do care and want to round it, you can create a rounding algorithm to call.

I dont think the /W2 or /W1 will be the solution, I have tried those methods in the past and not received the desired results. Rather then specify it however, you can just set the debug warning level in the options.

Lastly, you can declare temp as a float and not risk the loss of everything after the decimal.

Matt
 
Thanks Marcel, Brothi and Zyrenthian

My only "C" experience was a few years ago,
VAX ANSI C to do some user exits for an
ORACLE app. I'm between projects in my
company and this is my short-term
environment.

Marcel's:

temp = (int)( pri_scale_factor * ... );

looks the most promising.

btw,
I've only posted two requests in the VB
forums (both were not workable), but I've
posted many responses. I appreciate the
quick response.

Thanks, I'll be back.
Wayne

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top