Initial import of calc.c . needs cleanup