Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Converting numbers to and from roman numerals as easy as II+II=IV

License

NotificationsYou must be signed in to change notification settings

picrap/RomanNumerals

Repository files navigation

Converting numbers to and from roman numerals as easy as II+II=IV.
Available as aNuGet package package.

What is does

There are very few features:

  • Convert integers to roman numerals
  • Convert roman numerals to integers
  • Use roman numeral ASCII representation (I, II, III, IV)
  • Use roman numeral Unicode representation (Ⅰ, Ⅱ, Ⅲ, Ⅳ)
  • Use roman numeral vinculum extensions (V̅I̅=6000, I̿I̿=200000, etc.)
  • Use roman numeral apostrophus (C|Ɔ=1000, |ƆƆ=5000, CC|ƆƆ=10000, |ƆƆƆ=50000, CCC|ƆƆƆ=100000)
  • Use roman numeral apostrophus special characters (ↀ=1000, ↁ=5000, ↂ=10000, ↇ=50000, ↈ=100000)
  • Use of positive-only combinations (use ⅠⅠⅠⅠ instead of Ⅳ)

How it works

Simple way

To display:uint tostring (representing a Roman numeral)

Console.WriteLine(RomanNumerals.Convert.ToRomanNumerals(123));// CXXIIIConsole.WriteLine(RomanNumerals.Convert.ToRomanNumerals(227,NumeralFlags.Unicode));// ⅭⅭⅩⅩⅦ

Parsing:string touint

Console.WriteLine(RomanNumerals.Convert.FromRomanNumerals("IV"));// 4

All methods also works as extension methods:

usingRomanNumerals;vara1=Convert.ToRomanNumerals(123);vara2=123.ToRomanNumerals();// same as above 😍

With options

Formatting

Formatting is done using theNumeralBuilder class, with several options.NumeralBuilder implementsICustomFormatter with the following flags:

FlagEffect
0Don’t use negative digits (turns4 toIIII instead ofIV)
V or- or=Use vinculum notation (turns1,000 toĪ instead ofM, but also1,000,000 toI̿ or5,000,000 toV̿)
' or ``
uUse Unicode (subset of Unicode Roman numerals)
UUse Unicode plus ligatures (full range of Unicode Roman numerals)
AUse ASCII, the default case

Parsing

Parsing is done using theNumeralParser class (with less options, because it parses all forms at once).

Some documentation

Read more about roman numerals at

About

Converting numbers to and from roman numerals as easy as II+II=IV

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp