Monthly Archives: January 2011

Doing Math in Objective C

Share this:  


One thing you will find you need to do in any programming language is do math. Here are some useful math functions for the Objective C language. I give a little bit of a comparison to Visual Basic for those who know that language. They are provided in no special order:

  • fabs() – Gets the absolute value of the value in parentheses. Works like ABS() function in Visual Basic. fabs(-123) = 123, fabs(34) = 34.
  • ceil() – Find the ceiling integer. Kind of like rounding up. Same as INT(x+1) in Visual Basic.  ceil(3.1) = 4.
  • floor() – Find the floor integer. Kind of like rounding down. Same as INT(x) in Visual Basic. floor(3.6) = 3.
  • exp() – Find the exponential value.
  • pow() – Raise a number to the power. pow(3,6) = 3^6 in Visual Basic.
  • rand() – Generate a pseudo random number. Function is RND(x) in Visual Basic. A good discussion on random numbers in Objective C can be found here.
  • srandom() – Generate a seed for the random number generator. This is done with the Randomize statement in Visual Basic.
  • sqrt() – Find out the square root of a number. sqrt(x) = x^(1/2) in Visual Basic.

Book Review: RibbonX – Customizing the Office 2007 Ribbon

Share this:  

My Book Rating: 5 of 5 stars:

Power Users and Developers: Making customized Apps Using Microsoft Office
Those of us who have the responsibility of producing customized Excel workbooks, and Word documents that essentially have become small powerful applications in their own right are always looking for ways to make the tools we build in these Microsoft Office products more powerful, easy to use, and more like actual stand-alone apps. One of the ways I looked at enhancing the “tools” I created was by adding a tool bar to an Excel workbook for example. I first did this myself in Excel 2003. It was tedious but doable. One draw-back in the way tool bars were done back then is that the changes applied to the whole app (Excel or Word), and one screw-up on your part could truly clobber Excel or Word’s tool bars and menus system wide.

A New Way of Doing Tool Bars in Office 2007
In Office 2007, Microsoft changed how their user interface worked. And they changed the scope of the changes. If you were going to screw something up for your tool bars now it would only be with one document file, not the entire system. Customizing this tool bar was more flexible. You could do much more with the new tool bar than the old version (the new tool bar Microsoft calls a ribbon). The Technology behind the ribbon they call RibbonX. Read more