• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ceil woes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ceil woes


  • Subject: Re: ceil woes
  • From: Robert Dell <email@hidden>
  • Date: Fri, 03 Feb 2006 22:56:06 -0500

it was the math.h but i'm intrigued by the non-fp solution here...

Greg Herlihy wrote:

An "implicit declaration" means that the compiler has not seen any function
declaration to match the function call being made in the source code. For
some reason gcc by default merely warns about this condition when it
sensibly should flag it as an error - nothing good can come from it. (I
recommend adding ?Werror?implicit?function?declaration to XCode's compiler
flags to have gcc report an error when a function declaration appears to be
"missing").

The essential problem here is using floating point routines for what are
essentially integer operations. An in fact the floating point routines are
not really necessary. It's possible to perform the same calculation without
calling any external functions:

 mysurvival[i].skillvalue-(int)(calcCircle * 3.5 + 0.5 + 280)*100;

Instead of ceil, add 0.5 to round non-integral results up (since the result
of multiplying an integer by 3.5 will always end in either .0 or .5). The
lround is unnecessary since the value will be truncated. Finally, an "int"
cast should be used to tell the compiler that the float to integer
conversion is intentional.

Greg

On 2/3/06 2:57 AM, "Robert Dell" <email@hidden> wrote:


ok, i've been TRYING, searching the docs online, searching the /usr/include
folder, searching for programs that use it for anything that has ceil in it
but can't find anything to solve my problem.

the bad line is this:
mysurvival[i].skillreqs =
mysurvival[i].skillvalue-(lround(ceil((calcCircle*3.5)+280)*100));

mysurvival is defined as:
struct expskill
{
  long     skillvalue;
  long     skillreqs;
  long     skillNeeded;
  long     skillexclude;
  char     skillname[80];
} myArmor[8], myweapon[25], mymagic[5], mysurvival[15], mylore[13],
myinstruments[5], swap;

the warnings i'm getting are:
warning: incompatible implicit declaration of built-in function 'lround'
warning: incompatible implicit declaration of built-in function 'ceil'

At first, I was just getting the problem with ceil and then noticed it
returned double.  I then decided to convert the double to long and found
lround which looks to do the trick.  All it did was to add yet another
warning.

any suggestions?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden





_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: ceil woes (From: Greg Herlihy <email@hidden>)

  • Prev by Date: Re: File permissions when copying files using NSFileManager
  • Next by Date: replacing control characters in a NSMutableString
  • Previous by thread: Re: ceil woes
  • Next by thread: Property name clashes with a method implemented by NSManagesObject or NSObject
  • Index(es):
    • Date
    • Thread