Hi, I wrote an evil fixed point expression evaluator in C: http://www.coli.uni-sb.de/~eric/stuff/soft/specials/calc-fixpoint-expressions.zip
This program uses GPLed prf.c and is released under the Artistic License, I hope those two mix reasonably well... prf.c is a smaller printf (compared to default C library ones of e.g. Turbo C). The ZIP contains, apart from the prf sources, the C source file (500 lines), a Linux 386 binary (5 kB) and a DOS 8086 binary (5 kB). All binaries are UPX compressed. So, what the heck is this all about? > calc Usage: calc "math_expression" - shows the result. Example: calc "5.5 + 0.01 * (7.35 / 3) + 42" > calc "5.5 + 0.01 * (7.35 / 3) + 42" Result: 55.499499998 [0x37:7fdf3b55] As you notice, there are rounding errors (result should be 55.4995) and the calculations are left to right unless otherwise forced by (), so the * / % are NOT binding stronger than + - in this program! Apart from those arithmetical operators, & | and ^ are supported for and, or and xor. You can enter values in decimal or hexadecimal form: > calc "5.0x80000000 * 0x10.333333333 + 1 + (1/6)" Result: 90.99999999 [0x5a:ffffffd1] Mixed decimal and hexadecimal in one number is possible, too ;-). Pretty weird indeed. But on the other hand, we already had the very versatile Craig Hessel CALC387 (1 kB DOS binary, with Asm sources, requires 387 or newer floating point unit), so it was time for a crappy completely floating point free C thingy. Using compiler floating point replacement libraries to stay 8086 compatible would be too easy... My suggestion would be to add this to FreeDOS EDIT with a simple "edit formula in one field, get back values in other field" form, possibly with buttons for "close" "clear" and "paste" (default would be to keep the last formula stored in the form, so you have "clear", and "paste" pastes (or better call it copies?) the result to the clipboard...). Or maybe "copy/dec" and "copy/hex" instead of "paste"? If you do want a NORMAL calculator, I can recommend OSP EDIT. It has a pop-up calculator with + - * /, digits, =, del-digit, del- whole-value, change-sign and % (?) buttons. If you want a GOOD calculator, you better use CALC387. Example: > >calc387 (1+4*2^3-5/4%1) + 1E7 1.000003275E+7 >calc387 e*cos(pi) -2.71828 So far the calculator news for now. Enjoy :-). Eric PS: OSPEDIT is by Owen Rudge 2000/2001, GNU GPL, C++, with window zoom / size / move / tile / cascade / previous / next menu items and a built-in calculator and wave audio player. To compare to the FreeDOS EDIT, OSPEDIT lacks "format paragraph", calendar, built-in help function, configurability for tabs and display and clock. But as said, OSPEDIT has some nice window functions and the calculator. ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 _______________________________________________ Freedos-user mailing list Freedos-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-user