Skip to content

Rusk85/RomanNumeral

 
 

Repository files navigation

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 on nuget.org.

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.

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.

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.

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

About

A numeric type representing roman numerals.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%