Skip to content

Commit

Permalink
Fix README formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Limeoats authored May 25, 2017
1 parent e4bd192 commit 4a65e2d
Showing 1 changed file with 40 additions and 53 deletions.
93 changes: 40 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Then, simply include the header file in whichever file you need a BigNumber and
`#include "bignumber.h"`

## Usage
###`BigNumber(string)`
### `BigNumber(string)`


You can also use the `=` operator to set a BigNumber equal to an existing BigNumber, a number, or
Expand All @@ -34,203 +34,190 @@ Examples:
BigNumber h(22); //BigNumber h is created with value 22.


##Methods
###`add(BigNumber other)`
## Methods
### `add(BigNumber other)`
Adds another BigNumber to the current instance

`BigNumber("4").add(BigNumber("20")) => BigNumber("24")`

###`subtract(BigNumber other)`
### `subtract(BigNumber other)`
Subtracts another BigNumber from the current instance

`BigNumber("30").subtract(BigNumber("45")) => BigNumber("-15")`

###`multiply(BigNumber other)`
### `multiply(BigNumber other)`
Multiplies the BigNumber by another BigNumber

`BigNumber("12").multiply(BigNumber("4")) => BigNumber("48")`

###`divide(BigNumber other)`
### `divide(BigNumber other)`
Divides the BigNumber by another BigNumber

`BigNumber("30").divide(BigNumber("5")) => BigNumber("6")`

###`pow(int exponent)`
### `pow(int exponent)`
Raises the BigNumber to the power of the exponent

`BigNumber("2").pow(3) => BigNumber("8")`

###`getString()`
### `getString()`
Returns the BigNumber as an std::string

`BigNumber("3824").getString() => "3824"`

###`setString(std::string newStr)`
### `setString(std::string newStr)`
Sets the BigNumber's internal number string to a new string

`BigNumber("2847").setString("38") => BigNumber("38")`

###`negate()`
### `negate()`
Changes the sign of the BigNumber

BigNumber("3").negate() => BigNumber("-3")
BigNumber("-27").negate() => BigNumber("27")

###`equals(BigNumber other)`
### `equals(BigNumber other)`
Checks if the other BigNumber is equal to this one

`BigNumber("24").equals(BigNumber("28")) => false`

###`digits()`
### `digits()`
Returns the number of digits in the BigNumber

`BigNumber("28374").digits() => 5`

###`isNegative()`
### `isNegative()`
Determines whether a BigNumber is negative

`BigNumber("-278").isNegative() => true`

###`isPositive()`
### `isPositive()`
Determines whether a BigNumber is positive

`BigNumber("-3").isPositive() => false`

###`isEven()`
### `isEven()`
Determines whether a BigNumber is even

`BigNumber("28472310").isEven() => true`

###`isOdd()`
### `isOdd()`
Determines whether a BigNumber is odd

`BigNumber("283427").isOdd() => true`

###`abs()`
### `abs()`
Gets the absolute value of the BigNumber

`BigNumber("-26").abs() => BigNumber("26")`


##Operator overloads
## Operator overloads
The following operators have been overloaded to work with BigNumbers:

###`<<`
### `<<`
Output stream operator

`std::cout << BigNumber("26") << std::endl => 26`

###`+`
### `+`
Addition operator

`BigNumber("2") + BigNumber("4") => BigNumber("6")`

###`-`
### `-`
Subtraction operator

`BigNumber("0") - BigNumber("2000") => BigNumber("-2000")`

###`*`
### `*`
Multiplication operator

`BigNumber("-20") * BigNumber("-5") => BigNumber("100")`

###`/`
### `/`
Division operator

`BigNumber("10") / BigNumber("-2") => BigNumber("-5")`

###`==`
### `==`
Equal to operator

`BigNumber("24") == BigNumber("24") => true`

###`>`
### `>`
Greater than operator

`BigNumber("2") > BigNumber("6") => false`

###`<`
### `<`
Less than operator

`BigNumber("2") < BigNumber("6") => true`

###`>=`
### `>=`
Greater than or equal to operator

`BigNumber("34") >= BigNumber("22") => true`

###`<=`
### `<=`
Less than or equal to operator

`BigNumber("383") <= BigNumber("383") => true`

###`=`
### `=`
Assignment operator

`BigNumber c("3") = BigNumber("8") => BigNumber("8")`

###`+=`
### `+=`
Adds and assigns to the BigNumber

`BigNumber c("4") += BigNumber("3") => BigNumber("7")`

###`-=`
### `-=`
Subtracts and assigns to the BigNumber

`BigNumber c("28") -= BigNumber("3") => BigNumber("25")`

###`*=`
### `*=`
Multiplies and assigns to the BigNumber

`BigNumber c("3") *= BigNumber("4") => BigNumber("12")`

###`/=`
### `/=`
Divides and assigns to the BigNumber

`BigNumber c("30") /= BigNumber("30") => BigNumer("1")`

###`++ (Prefix)`
### `++ (Prefix)`
Increments the BigNumber and returns the newly incremented number

`++BigNumber("10") => BigNumber("11")`

###`-- (Prefix)`
### `-- (Prefix)`
Decrements the BigNumber and returns the newly decremented number

`--BigNumber("34") => BigNumber("33")`

###`++ (Postfix)`
### `++ (Postfix)`
Increments the BigNumber but returns the original value

`BigNumber("20")++ => BigNumber("20")`

###`-- (Postfix)`
### `-- (Postfix)`
Decrements the BigNumber but returns the original value

`BigNumber("14")-- => BigNumber("14")`

###`[]`
### `[]`
Indexing operator

`BigNumber d("26")[1] => 6`

##License
## License
This project is under the [Apache License](https://github.com/Limeoats/BigNumber/blob/master/LICENSE.md).

##Credit
## Credit
The BigNumber class was created by [Mark Guerra](http://www.twitter.com/Limeoats). Visit
[Limeoats.com](http://www.limeoats.com) for more information.













0 comments on commit 4a65e2d

Please sign in to comment.