convert.intToRoman ( )

Function stats

Average user rating
29
220
9999
Support
FileMaker 7.0 +
Date posted
04 May 2009
Version
1
Recursive function
No

Author Info
 Genx

18 functions

Average Rating 4.1

author_avatar



 

Function overview

Prototype

convert.intToRoman  ( num )


Parameters

num  The number you would like to convert to roman numerals


Description

Tags:  Roman Numerals   Number   Math   Convert   Arabic  

Non recursive function that converts numbers to roman numerals.

Examples

Sample input

convert.intToRoman( 4166 )


Sample output

MMMMCLXVI

 

Function code

Let([
    _string = RepeatPlus("M";Floor(num / 1000));
    num = Mod(num;1000);
    _string = _string & RepeatPlus("CM";Floor(num / 900));
    num = Mod(num;900);
    _string = _string & RepeatPlus("D";Floor(num / 500));
    num = Mod(num;500);
    _string = _string & RepeatPlus("CD";Floor(num / 400));
    num = Mod(num;400);
    _string = _string & RepeatPlus("C";Floor(num / 100));
    num = Mod(num;100);
    _string = _string & RepeatPlus("XC";Floor(num / 90));
    num = Mod(num ; 90);
    _string = _string & RepeatPlus("L";Floor(num / 50));
    num = Mod(num ; 50 );
    _string = _string & RepeatPlus("XL";Floor(num / 40 ));
    num = Mod(num ; 40 );
    _string = _string & RepeatPlus("X";Floor(num / 10 ));
    num = Mod(num ; 10 );
    _string = _string & RepeatPlus("IX";Floor(num / 9 ));
    num = Mod(num ; 9 );
    _string = _string & RepeatPlus("V";Floor(num / 5 ));
    num = Mod(num ; 5 );
    _string = _string & RepeatPlus("IV";Floor(num / 4));
    num = Mod(num ; 4 );
    _string = _string & RepeatPlus("I";num)
];
    _string
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/220

    Prototype: convert.intToRoman( num )
    Function Author: Genx (http://www.fmfunctions.com/mid/29)
    Last updated: 04 May 2009
    Version: 1

*/
// ===================================

 

Comments

Fabrice
05 May 2009



How about zeros ?
(just kidding)
Thanks !
  General comment
Robert Schaub
05 May 2009



Did you forget to mention this requires function RepeatPlus? And where's my link to Capture Custom Functions? 8-)
  General comment
Genx
02 December 2010



Delayed but... you'll see that the RepeatPlus function is listed a required function off to the right.
  General comment

 

 

 

 

 

Related Functions

Required functions