Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.
/ cachingcalculator Public archive

A reactive arbitrary-precision RESTful calculator service that caches the results of its computations.

Notifications You must be signed in to change notification settings

mplevako/cachingcalculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This is a reactive implementation of a RESTful calculator service, that supports addition, subtraction, multiplication, division as well as exponentiation of arbitrary-precision signed decimal numbers. It also supports result caching, so if there is more than one call for the same operation on the same numbers, the result is returned from the cache rather than being recomputed.

Endpoints

To add, subtract, multiply, divide numbers or raise them to some power, issue an HTTP GET call to a corresponding endpoint (note that for the operations of addition, subtraction, and multiplication, the calculator endpoints support an input of up to three numbers in the same call):

/add/{a}/{b}/{c}

/subtract/{a}/{b}/{c}

/multiply/{a}/{b}/{c}

/divide/{a}/{b}

/pow/{a}/{b}

The result is a JSON object, containing either a result field with the calculated result or an errors array in case there are any errors. The second parameter (the exponent) for the pow endpoint should be a valid integer number from the [0,999999999] range, all other parameters may be arbitrary-precision signed decimal numbers written either in decimal or exponential notation. 0 to the 0th power equals 1, division of any non-zero number by 0 returns an error and the operation of dividing 0 by 0 is undefined. If a division renders a non-terminating decimal expansion/no exact representable decimal result, an error is returned.

Running

Download Apache Maven and follow the installation instructions. After that, type

mvn spring-boot:run

in a terminal or in a command prompt. The server will bind to localhost:8080 by default.

About

A reactive arbitrary-precision RESTful calculator service that caches the results of its computations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages