roman-numerals

Roman numerals to integers

落花浮王杯 提交于 2019-11-28 08:40:44
I have a transfer with products that unfortunately has to get matched by product name. The biggest issue here is I might get duplicate products on account of roman numbers. Sometimes the same product will be named with a roman number, other times it will be a regular one. I was googling for maybe a already made string function to convert this, but had no luck. I guess it wouldn't be that hard to make my own, but I would love to hear some opinions on how to handle the situation, and also if you know an already made function that does this, name it. EDIT: The products are mobile gadgets. Example

How to convert a Roman numeral to integer in PHP?

隐身守侯 提交于 2019-11-27 11:12:20
问题 Using PHP, I'd like to convert a string containing a Roman number into its integer representation. I need this because I need to make calculations on them. Wikipedia on Roman numerals It would suffice to only recognize the basic Roman numeral characters, like: $roman_values=array( 'I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000, ); That means the highest possible number is 3999 (MMMCMXCIX). I will use N to represent zero, other than that only positive integers

Converting integers to roman numerals

非 Y 不嫁゛ 提交于 2019-11-27 10:55:27
I'm trying to write a function that converts numbers to roman numerals. This is my code so far; however, it only works with numbers that are less than 400. Is there a quick and easy way to do this conversion, or extend my existing code so that it handles all cases? Thanks in advance for any help. static string convertroman(int number) { int l = number / 10; StringBuilder sb = new StringBuilder(); for (int m = 0; m <= l; m++) { if (l == 0) { break; } if (l == 5) { sb = sb.Append(ro.L.ToString()); break; } if (l == 4) { sb = sb.Append(ro.X.ToString()).Append(ro.L.ToString()); break; } if (l == 9

How do you find a roman numeral equivalent of an integer

丶灬走出姿态 提交于 2019-11-27 08:18:40
How do you find a roman numeral equivalent of an integer. Is there a java library which provides this capability? I did find a similar question , but I would prefer an out of the box API abstraction for this issue. Its just painful to handle all possible combinations in your code. Petar Minchev Here is a link for many languages including Java. Here's an extract of relevance: public class RN { enum Numeral { I(1), IV(4), V(5), IX(9), X(10), XL(40), L(50), XC(90), C(100), CD(400), D(500), CM(900), M(1000); int weight; Numeral(int weight) { this.weight = weight; } }; public static String roman

Convert roman numerals to numbers in R

浪子不回头ぞ 提交于 2019-11-27 03:53:51
问题 In R, there is a great function as.roman in the very base setup: as.roman(79) # [1] LXXIX Is there an inverse function that would convert roman numerals to numbers? (I know I can write it myself but I prefer to use already prepared or preferably standard functions, unfortunatelly cannot find one. Standard library or package function is a prefered solution) 回答1: as.roman() returns an object of class roman , so R recognizes it as such. You can directly turn it back into an Arabic numeral with

How to convert integer value to Roman numeral string?

对着背影说爱祢 提交于 2019-11-27 03:51:10
How can I convert an integer to its String representation in Roman numerals in C ? paxdiablo The easiest way is probably to set up three arrays for the complex cases and use a simple function like: // convertToRoman: // In: val: value to convert. // res: buffer to hold result. // Out: n/a // Cav: caller responsible for buffer size. void convertToRoman (unsigned int val, char *res) { char *huns[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}; char *tens[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}; char *ones[] = {"", "I", "II", "III", "IV", "V", "VI", "VII"

Code Golf New Year Edition - Integer to Roman Numeral

為{幸葍}努か 提交于 2019-11-27 02:38:45
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Write a program that take a single command line argument N and prints out the corresponding Roman Numeral. Eg N = 2009 should print MMIX. Let's say this should work for 0 < N < 3000. (Had fun playing my first ever round of code golf with the Christmas edition, and thought this could fit for New Year. Googled to see if

Roman numerals to integers

筅森魡賤 提交于 2019-11-27 02:20:42
问题 I have a transfer with products that unfortunately has to get matched by product name. The biggest issue here is I might get duplicate products on account of roman numbers. Sometimes the same product will be named with a roman number, other times it will be a regular one. I was googling for maybe a already made string function to convert this, but had no luck. I guess it wouldn't be that hard to make my own, but I would love to hear some opinions on how to handle the situation, and also if

Converting integers to roman numerals

浪子不回头ぞ 提交于 2019-11-26 17:58:35
问题 I'm trying to write a function that converts numbers to roman numerals. This is my code so far; however, it only works with numbers that are less than 400. Is there a quick and easy way to do this conversion, or extend my existing code so that it handles all cases? Thanks in advance for any help. static string convertroman(int number) { int l = number / 10; StringBuilder sb = new StringBuilder(); for (int m = 0; m <= l; m++) { if (l == 0) { break; } if (l == 5) { sb = sb.Append(ro.L.ToString(

Converting Integers to Roman Numerals - Java

ぃ、小莉子 提交于 2019-11-26 17:07:10
This is a homework assignment I am having trouble with. I need to make an integer to Roman Numeral converter using a method. Later, I must then use the program to write out 1 to 3999 in Roman numerals, so hardcoding is out. My code below is very bare-bones; it is a basic I/O loop with a way to exit while using a package for getIntegerFromUser we made in class. Is there a way to assign values to Strings and then add them together when I call the method? Update: I got some pseudo code from my professor to help me, and while I understand what he is trying to say, I am having some trouble with the