Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6079393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:56:29+00:00 2026-05-23T10:56:29+00:00

Possible Duplicate: How to convert integer value to Roman numeral string? Back in my

  • 0

Possible Duplicate:
How to convert integer value to Roman numeral string?

Back in my college days, when learning C and all i had come across a question of representing a year in its corresponding Roman Numeral form. There was no solution in that text, as it was among some extra questions to ponder. All i could think of was using modulus operator and a bunch of ifs. I was wondering if some one could give me a proper solution. A simple algorithm or explanation of the logic used would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:56:29+00:00Added an answer on May 23, 2026 at 10:56 am

    Here’s logic for numbers less than 4,000. (See below for what to do above that.) There’s a basic, 4-step algorithm that is applied at each level of magnitude.

    1. Determine the number of thousands in the number: floor(number/1000). Output that many “M”s and subtract that many thousands from the number. At this point, the number is less than 1,000.

    2. If the number is >= 900, output “CM” and subtract 900.

    3. If the number is >= 500, output “D” and subtract 500.

    4. If the number is >= 400, output “CD” and subtract 400.

    At this point, the number is guaranteed to be < 400. We follow a similar pattern to reduce the number to less than 40:

    1. Determine the number of hundreds in the number, output that many “C”s and subtract that many hundreds from the number. At this point, the number is less than 100.

    2. If the number is >= 90, output “XC” and subtract 900.

    3. If the number is >= 50, output “L” and subtract 50.

    4. If the number is >= 40, output “XL” and subtract 40.

    At this point, the number is guaranteed to be < 40. We repeat exactly the same logic using “X”, “IX”, “V”, and “IV”. We finish by using the number (guaranteed to be < 4) as the count of how many “I”s to output.

    For larger numbers, the logic is still the same, we just use the standard symbols with bars on top. Each bar represents 1,000 times the value without that bar. (So V with a bar is 5,000, etc.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Convert.ToInt32() a string with Commas i have a value in the label
Possible Duplicate: How do I convert hex string into signed integer? example:3A convert to
Possible Duplicate: convert string to integer in c++ Convert a no. from string to
Possible Duplicate: convert integer to a string in a given numeric base in python
Possible Duplicate: How do I convert a string into an integer in objective C?
Possible Duplicate: How to convert from int to string in objective c: example code…
Possible Duplicate: convert string to 2D array using php I have the string like
Possible Duplicate: Convert seconds to days, minutes, and hours in Obj-c How to do
Possible Duplicate: Convert string to float in Objective-C I'd like to convert a string
Possible Duplicate: Java: convert List<String> to a join()d string Having this: List<String> elementNames =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.