Giter VIP home page Giter VIP logo

compcalcnumbers's Introduction

CompCalcNumbers

An answer to an assignment in the class "Introduction to the Design of Computational Calculi".

Assignment

Design a calculus for the Arabic numbers with an Add operation. Extra credit to include Roman numerals.

Answer

Let there be an ordered set of symbols where the first in the set represents zero. For example, in base 10 Arabic use "0123456789". Each subsequent member of the set is one greater than the previous.

Counting up

Define a counting up (increase by one) operation where:

  • Start from the right, reading the right most symbol
  • Replace this symbol with the next greater symbol
  • If there is no next greater symbol, replace the symbol with the first symbol and perform a carry, else stop.
  • To carry, move left one character, and repeat counting up operation.

Counting down

Define a counting down (decrease by one) operation where:

  • Start from the right, reading the right most symbol
  • Replace this symbol with the previous symbol
  • If there is no next previous symbol, replace the symbol with the last symbol and borrow, else stop.
  • To borrow, move left one character, and repeat counting down operation.

Detecting Zero

A value with only one symbol and that symbol is the first symbol of the set has a value of zero, otherwise it is non-zero.

Adding

Adding is defined in terms counting up the amount of the amount to add.

V = the current value Arg = the amount to add

Count up V, and count down Arg until Arg is zero.

Implementation

The implementation supports positive and negative values, Add, Subtract, and Roman numerals, and base 2, 8, 10, and 16 of Arabic numerals. The code is at https://github.com/glenbraun/CompCalcNumbers/blob/master/num/Program.fs

compcalcnumbers's People

Contributors

glenbraun avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.