Re: Question
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Wed, 11 Jun 2008 23:34:19 -0400
Max wrote:
On 11 Jun 2008 21:23:46 GMT, richard@xxxxxxxxxxxxxxx (Richard Tobin) wrote:
In article <1292858.4WXqv0htDk@xxxxxxxx>, Max <invalid@xxxxxxxxxxxxxxx> wrote:
Can I ask C questions here?I don't know. Why not give it a try and see if you're up to it?
If I compile this function
unsigned short div(unsigned short a, unsigned short b)
{
return a / b;
}
with warnings turned on, I am informed that
Warning test.c: 3 Assignment of int to unsigned short. Possible loss of precision
Warning test.c: 4 Assignment of int to unsigned short. Possible loss of precision
Warning test.c: 4 Assignment of int to unsigned short. Possible loss of precision
(line 3 is the line with the return statement, line 4 is the line with the closing brace)
(1) What does that mean, specifically, what is precision in this context?
(2) How do I get rid of them? I tried all sorts of casts, unsuccessfully. In a program with lots of such functions,
real problems can easily get lost, but I don't want to disable warnings.
/* BEGIN test.h */
#ifndef H_TEST_H
#define H_TEST_H
#define DIVIDE(A, B) ((unsigned short) ((A) / (B)))
#endif
/* END test.h */
--
pete
.
- References:
- Question
- From: Max
- Re: Question
- From: Richard Tobin
- Re: Question
- From: Max
- Question
- Prev by Date: Re: doubt on char *
- Next by Date: Re: Question
- Previous by thread: Re: Question
- Next by thread: Re: Question
- Index(es):
Relevant Pages
|