[Project] Programmer's Calculator

Discussion in 'The Common Room' started by Elf, Jun 29, 2015.

  1. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    Two things are true: I need to use C# more to become fluent with it, and I have never found a good programmer's calculator. I am somewhat concerned with Java's future under Oracle (I still think that Java is a better language and platform than C#), and C# is the next best thing (being basically hackier Java). I am also not as concerned with portability for desktop applications these days (unfortunately). Anyways...

    A programmer's calculator is a calculator that can deal natively with numbers in the common bases: 2 (binary), 8 (octal), 10 (decimal), and 16 (hexadecimal). The "Programmer" mode of the modern Windows calculator works for basic functions, but has many limitations. For example: it tops out at 64 bits and does not allow you to manipulate individual digits in a number.

    So as a fun and simple project to familiarize myself with C# I am making a new programmer's calculator. The end goals are:
    • Register / stack based calculator functionality (unambiguous order of operations), with loading/saving of the stack
    • The ability to deal with register sizes (numbers) ranging from 8 bit to 256 bit (in 8 bit increments), signed and unsigned, with endian swapping
    • The ability to handle operations that result in overflows and display the correct results (and overflow status) as a CPU operation would
    • The ability to display and manipulate numbers in binary, octal, decimal, and hexadecimal in any kind of mixed combination
    • Manipulating numbers in any register field as bit flags (with a function to save and restore sets of bit flag labels)
    • Displaying and interpreting numbers as:
      • Colors: 8-bit palettized w/ palette load/save, through 16, 24 and 32-bit in various pixel formats
      • IPv4 and IPv6 internet addresses with bitmasks, and built-in CIDR calculator
      • UNIX file permissions (special case of bit flags)
    • Windows GUI (WPF/XAML) interface, maybe also command line?
    So far I have just about finished the variable sized register library functions which seems to work well. A little more work on the data manipulation side and then I can start on the GUI pieces. The finished application will be free to use but I will probably not release the source.

    (u7:doodad_snake)
     
  2. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    Started writing unit tests against the (finsihed) library. Unit tests in C# are actually pretty simple to write...

    UnitTest.PNG
     
  3. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    Some delay due to the drive down to Santa Barbara, but I finished writing all of the unit tests against the library. 32 main tests in 4 modules, each test breaking out to a whole set of checks. Still not comprehensive coverage (sort of difficult to do against something that does math), but after some fixes everything passes.

    unit_tests.PNG

    Time to move on to XAML GUI stuff.