Periodically I get requests to release CCalc for Mac OS X. Also for Unix, but I don’t have any experience with GUI development in Unix, and I’ve heard that CCalc runs fairly well under Wine anyway.

Years ago I began experimenting with OS X development for Console Calculator, as I use OS X personally. To be honest, I can’t stand using Xcode to design an interactive GUI. I find it confusing an non-intuitive for one. The NIB files and Interface Builder seem particularly convoluted with all their controllers, and control-click to drag objects to connect them together. Are events and callbacks so bad?

Even though I had mostly separated the calculator engine from the GUI, it was going to take a LOT of work to get a fully featured OS X version of the GUI and and running.

I started thinking about going with a cross-platform development kit, so I looked into a few. wxWidgets had some nice things going for it, but I also gave FLTK a try and found developing with that toolkit was easier and produced smaller executables.

FLTK stands for Fast Light ToolKit.  It’s free.  Here’s the skinny from their site:

FLTK (pronounced “fulltick”) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. FLTK provides modern GUI functionality without the bloat and supports 3D graphics via OpenGL and its built-in GLUT emulation.

FLTK is designed to be small and modular enough to be statically linked, but works fine as a shared library. FLTK also includes an excellent UI builder called FLUID that can be used to create applications in minutes.

I found it really easy to pick up, documentation is good (if you use google to find it, their website is a mess), and their sample applications are great way to learn the ropes.  I had a simple console calculator GUI up and running in just a few hours.  With a cross platform toolkit, I figured the examples wouldn’t work “out of the box” on OS X as they would on Windows, but I was wrong.  Xcode project files were included, and the sample applications compiled right away.  No hours spent to read install READMEs and googling for compile errors.  Nice.

So I spent a few more hours to make it actually a useable program, and released the half-baked version for download.  It’s got the same calculator engine as the Windows version, so it is fully featured in that regard, but no GUI support for changing any of the settings yet, no saved variables or functions.  To get it on par with the Windows version will take many more hours, and unless someone wants to sponsor further development, I’m in no rush.

Try out Console Calculator for OS X.  I would like to hear some feedback from people… the GUI doesn’t use native OS X controls, so it does look a little out of place.  The menu bar is in the application window, etc. Could use some polishing, but works for me.

  • New feature: Display option to never use SCI notation.
  • New feature: Comparison operators supported: <, <=, >, >=, ==, !=
  • New feature: Logical AND and OR (C-type) operators supported: &&, ||
  • Bug fixed: occasional loss of saved functions and variables.
  • Bug fixed: occasional memory leak.
  • Several other interface tweaks and improvements.
  • (2010-01-02)

A common request I get for Console Calculator is support for a bitwise NOT operator (the ~ symbol in many programming languages).  The reason I have not yet implemented this is that CCalc has a very large intrinsic bit width (200+ bits).  A proper NOT operator cannot ignore leading zeros, so how many bits should I limit to?  Should ~0×80 be 0x7F or 0xFF7F or 0xFFFFFF7F, etc.

Anyway, you can define your own NOT function to the bit width you prefer.

not16(x)=0xFFFF-x
not32(x)=0xFFFFFFFF-x

Below are a few additional useful functions which I like to have around.

gain2db(gain)=20*log10(gain)
db2gain(db)=10^(db/20)
norm(x,y)=sqrt(x^2+y^2)
norm(x,y,z)=sqrt(x^2+y^2+z^2)
twoscomp16(x)=(0xFFFF+1+x)&0xFFFF
twoscomp32(x)=(0xFFFFFFFF+1+x)&0xFFFFFFFF
max(a,b)=a*(a>=b)+b*(b>a)
min(a,b)=a*(a<=b)+b*(b<a)

Do you have any useful custom functions you’ve defined?  Comment.

ZoeSoft is mostly just a place to park my calculator, Console Calculator, and a few other tidbits here and there.  I developed the first version of CCalc years ago while I was in grad school, to help me with various engineering assignments.  I didn’t like to fire up Matlab, and I couldn’t find any other calculator out there with the user interface and features I wanted.

So I began to create the PC-based calculator that I wanted to use.

I might not have endeavored on such a project if I had known how long it would take (it sounded so simple!) and how little I knew about programming (at that time).  But eventually, CCalc has turned into one of my favorite tools to use, highly functional, and fun to use!  (Fun being a relative term in this context.)  I hope you enjoy it too.

  • New feature: Display option using SI-Unit prefixes.
  • New feature: Command history matching.
  • USB thumbdrive friendly. Replaced windows registry with INI file.
  • Minor bug fixes.
  • (2008-08-28)