1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

dream calculator

Discussion in 'Mac Programming' started by liptonlover, Sep 1, 2008.

  1. macrumors 6502a

    What do you look for in a calculator for programming? I am currently making a new ProgramoCalc with features for everyone. The main one though will be that it will remember, and display in a list, every calculation you save. But this isn't the only feature I want to add. So you guys, as developers, please tell me what you want.

    Do you want to be able to convert between hex, binary and decimal?
    Do you want to be able to edit past calculations?
    Do you want the calculator to automatically put the calculations saved into an equation?
    Do you want what my calculator currently has, where it uses a HUD window so it's always available?

    Or anything else you can think of. If you want it, say it. I may have to have an advanced mode as well as the default.
  2. macrumors 6502a

    I would like a calc that shows decimal, hex, binary and octal all at the same time (as opposed to having to flip between different modes).

    Also, a calc that can accept a hex value and treat it as signed when converting to other formats.

    A calc that can show both an ascii and ebcdic eyecatcher area if I paste in a portion of raw storage.

    A calc that can handle both big and little endian in the above situation.

    A calc that will work with floating point values, for instance, entering -45.678e-2 and seeing the double value that will be stored on a little endian machine.

  3. macrumors 65816

    I was starting to think about writing a modular calculator that would run as a server on your machine and you (or others) would connect to it with graphical clients that could be customized in two panes - controls and output. I was going to provide an API to add more controls/calculations for programmers and some sort of scripting method for non-programmers. Of course, if I had the time to implement every idea I ever had then I would probably exist outside of time itself.

    To add to what Todd said, I'd like a calculator that can display signed and unsigned representations of numbers at the same time. Also, big and little endian are nice, but also being able to specify the byte size representation of larger values on those machines. For example, suppose I'm storing a 32-bit number as two 16-byte values on a little endian machine and want to see a representation of that. I guess you could simply allow the user to select byte boundaries or something. *shrug*

    Don't forget it should be able to play super mario bros! ;)
  4. macrumors 68040


    I second most everything todd said, but wanted to add to this part, specifically. There needs to be a way, after you've entered a value, to say "oops, nope, that was in octal", or just have a different area to enter hex, binary, octal, and decimal. The problem I have most often is that I (better case) copy an octal value, paste it in the calculator to find it's in hex mode, switch it, then paste again. The worser case is that it was only a 5 octet or so number and I just remembered it long enough to enter it in the calculator to find that it was in the wrong mode, then have to switch it (at which point i can no longer rely on the calculator as it has converted) and check the value again and re-enter.

    Other than that I don't know that I have much to add. Display of text equivalence would be quite nice, and I'll add to that entry of text and getting the byte equivalence in hex, octal, binary and (while we're at it, i guess) decimal.

  5. macrumors 6502a

    Hmmm... I think I'm going to have to add an advanced mode to my calculator. Adding all that would go against my main goal-keeping it as small as possible. Also a lot of those things I don't even know what they are/how to implement them... at least right now. So I'll have to do some research. But keep the ideas coming!
  6. macrumors 6502a

    Since we're talking advanced mode now, it would be nice (we're talking "dream calculator", right?) to be able to pick a base, like 36, or 5, or whatever.

    Also, a "goal to keep it as small as possible" and "dream calculator" are somewhat mutually exclusive.

    XOR, Bit Inverse, OR and AND operations would be nice too. ;)

    And of course powers, logs, natural logs and compound interest. would be nice too. Matter of fact, here's some C code that does all manners of compound interest. (Compound continuously as well)

    #include <stdio.h>
    #include <math.h> 
    #include <sys/time.h> 
    double pv, fv, rate, years, periods ; 
    double get_years() { 
    	return log(fv/pv) / (periods * log(1.0 + (rate/periods))) ; 
    double get_cont_years() { 
    	return log( fv / pv) / rate ; 
    double get_rate() { 
    	return periods * ( pow( ( fv / pv), 1.0 / (periods * years) ) - 1.0 ) ;  
    double get_cont_rate() { 
    	return log( fv / pv) / years ; 
    double get_fv() { 
    	return pv * pow(1 + (rate / periods), years * periods) ; 
    double get_cont_fv() { 
    	return pv * exp(rate * years) ; 
    double get_pv() { 
    	return (fv / pow( (1.0 + (rate / periods)) , periods * years) ) ; // (exp(rate * years * periods) )  ) ; 
    double get_cont_pv() { 
    	return (fv / (exp(rate * years) )  ) ; 
    void report(double n ) { 
    	periods = n ; 
    	printf("FV     : Rate=%lf, PV=%03.2lf, Years=%lf, Periods=%d, FV=%0.2lf\n", rate, pv, years, (int) periods, get_fv() ); 
    	printf("YEARS  : Rate=%lf, PV=%03.2lf, Years=%lf, Periods=%d, FV=%0.2lf\n", rate, pv, get_years(), (int)periods, fv ); 
    	printf("PV     : Rate=%lf, PV=%03.2lf, Years=%lf, Periods=%d, FV=%0.2lf\n", rate, get_pv(), years, (int)periods, fv ); 
    	printf("RATE   : Rate=%lf, PV=%03.2lf, Years=%lf, Periods=%d, FV=%0.2lf\n", get_rate(), pv, years, (int)periods, fv ); 
    	printf("\n") ; 
    void report_e() { 
    	printf("FV     : Rate=%lf, PV=%03.2lf, Years=%lf, FV=%0.2lf\n", rate, pv, years, get_cont_fv() ); 
    	printf("YEARS  : Rate=%lf, PV=%03.2lf, Years=%lf, FV=%0.2lf\n", rate, pv, get_cont_years(), fv ); 
    	printf("PV     : Rate=%lf, PV=%03.2lf, Years=%lf, FV=%0.2lf\n", rate, get_cont_pv(), years, fv ); 
    	printf("RATE   : Rate=%lf, PV=%03.2lf, Years=%lf, FV=%0.2lf\n", get_cont_rate(), pv, years, fv ); 
    	printf("\n") ; 
    int main (int argc, const char * argv[]) {
    	int rc ; 
    	struct timeval tv_start, tv_end ; 
    	struct timezone tz ; 
    	rc = gettimeofday(&tv_start, &tz) ; 
    	if (rc) { 
    		printf("gettimeofday() failed, rc = %d\n", rc) ; 
    		return rc ; 
    	pv = 100.0 ; 
    	fv = 110.0 ; 
    	rate = .10 ; 
    	years = 1.0 ; 
    	periods = 12.0 ; 
    	printf("Compounded Yearly\n") ; 
    	report(1.0) ; 
    	printf("Compounded Semi Anuallly\n") ; 
    	report(2.0) ; 
    	printf("Compounded Quarterly\n") ; 
    	report(4.0) ; 
    	printf("Compounded Monthly\n") ; 
    	report(12.0) ; 
    	printf("Compounded Daily\n") ; 
    	report(365.0) ; 
    	printf("Compounded Hourly\n") ; 
    	report(365.0 * 24.0) ; 
    	printf("Compounded Continuously\n") ; 
    	report_e() ; 
    //	getchar() ; 
    	rc = gettimeofday(&tv_end, &tz) ; 
    	if (rc) { 
    		printf("gettimeofday() failed, rc = %d\n", rc) ; 
    		return rc ; 
    	printf("tv_start = %ld.%ld, tv_end = %ld.%ld\n", tv_start.tv_sec, tv_start.tv_usec, tv_end.tv_sec, tv_end.tv_usec) ; 
    	if ( tv_end.tv_usec < tv_start.tv_usec) { 
    	//	printf("tv_start_usec - tv_end_usec = %d\n", tv_start.tv_usec - tv_end.tv_usec) ; 
    		tv_end.tv_sec-- ;            // borrow from seconds 
    		tv_end.tv_usec += 1000000 ;  // a usec is 1 milllionth of a second. 
    	printf("Elapsed Time (seconds) was %ld.%06ld\n", (tv_end.tv_sec- tv_start.tv_sec), (tv_end.tv_usec - tv_start.tv_usec))  ; 
    	return 0;
  7. macrumors 603


    Yep having a calculator that can work in any base would be extremely handy for people who want to do low level programming. Plus having a simple mode enabling you to switch numbers between different bases would be pretty handy.

    Oh and trigonometric functions would be cool too.
  8. macrumors 6502a

    lol we're talking dream calculator but within my skills to hopefully create. And by small I mean small area on the screen. After all, it's geared towards developers who usually have a lot of windows open.
  9. macrumors 6502

    So put a suggestion that all developers buy a 30" monitor :D (... no, I haven't followed my own advice...yet...)
  10. macrumors 6502a

    I've got a 20"... it's still not enough :eek:

    Besides the whole idea is it's free... not go spend 2k on a new monitor :D
  11. macrumors 603


    No need to make it a huge UI. Just make a few decisions on tabbing etc.
  12. macrumors 6502a


  13. macrumors 603


  14. macrumors 65816

    If you want to take up as little screen as possible, how about it be entirely voice activated and flash the results in morse code with the caps lock light on the keyboard? :D
  15. macrumors 6502a


    An RPN input stack, just like the HP calculators I used throughout college.
  16. macrumors demi-god


    I love my 50g. :cool:

Share This Page