Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamfisher/romannumeral
A numeric type representing roman numerals.
https://github.com/adamfisher/romannumeral
math roman-number roman-number-converter roman-numerals
Last synced: 26 days ago
JSON representation
A numeric type representing roman numerals.
- Host: GitHub
- URL: https://github.com/adamfisher/romannumeral
- Owner: adamfisher
- License: mit
- Created: 2015-09-12T19:19:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-06-10T03:13:51.000Z (over 1 year ago)
- Last Synced: 2024-11-09T18:08:31.178Z (about 1 month ago)
- Topics: math, roman-number, roman-number-converter, roman-numerals
- Language: C#
- Size: 102 KB
- Stars: 3
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ![](https://raw.githubusercontent.com/adamfisher/RomanNumeral/master/icon.png) RomanNumeral
This is a C# .NET data type representation of the numeric system used in ancient Rome, employing combinations of letters from the Latin alphabet. Permissible values fall within the range of 1 - 3,999.This package is available as a [**Nuget package**](https://www.nuget.org/packages/RomanNumeral) on nuget.org.
```Math
I, II, III, IV, V, VI, VII, VIII, IX, X ...
```## Getting Started
### Creation
Several convenience constructors give you the ability to create a roman numeral data type using either a numeric value or a roman numeral string. Once a `RomanNumeral` object is created, its value is static for the duration of its lifetime.
```csharp
var numberOne = new RomanNumeral(411); // CDXI
var numberTwo = new RomanNumeral("MCMXC"); // 1990
Console.WriteLine(new RomanNumeral(31)); // XXXI
```### Conversion
Convert a roman numeral string to a numeric value.
```csharp
int value;
if (RomanNumeral.TryParse(romanNumeral, out value))
{
// Do something with the converted value.
}
```### Math
You can treat a RomanNumeral type just like you would treat any other numeric type to perform math operations.
```csharp
var numberOne = new RomanNumeral(10);
var numberTwo = new RomanNumeral(5);Console.WriteLine(numberOne * numberTwo); // L
Console.WriteLine(numberOne / numberTwo); // II
Console.WriteLine(numberOne + numberTwo); // XV
Console.WriteLine(numberOne - numberTwo); // V
```