Y-Less/roman-numerals
Code using Roman numerals (I, V, X, etc.) instead of silly Arabic ones.
Mit sampctl installieren
sampctl package install Y-Less/roman-numerals
Führe das in deinem Projektordner aus. sampctl lädt das Paket und alles herunter, wovon es abhängt.
Fügt seine Include-Dateien samt der Bibliotheken, von denen es abhängt, dem Pawn-Compiler in deinem Browser hinzu, bereit zum Einbinden in ein Skript.
README.md
roman-numerals
Installation
Simply install to your project:
sampctl package install Y-Less/roman-numerals
Include in your code and begin using the library:
#include <roman-numerals>
Usage
There are two ways to use this include - prefixed and unprefixed (default):
#define ROMAN_LITERALS
#include <roman-numerals>
#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS (CC)
main()
{
for (new i = nulla; i != XCIV; ++i)
{
printf("i + CIII = %d", i + CIII);
}
}
Prefixed mode requires 0r in front of the numbers, but improves compatibility:
#define ROMAN_PREFIX
#define ROMAN_LITERALS
#include <roman-numerals>
#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS (0rCC)
main()
{
for (new i = 0rN; i != 0rXCIV; ++i)
{
printf("i + 0rCIII = %d", i + 0rCIII);
}
}
Note that there's no Roman numeral for zero, use nulla or 0rN instead. ROMAN_LITERALS includes the defines to make the numbers work (since there are several thousand of them). Without this you can't use the literals, but can still use the two functions for converting to and from strings:
// Remove this for much faster compiling.
//#define ROMAN_LITERALS
#include <a_samp>
#include "roman-numerals.inc"
main()
{
printf("%d", FromRomanNumeral("MCCVIIII"))
new str[32];
ToRomanNumeral(54, str, .subtractive = false);
printf(str); // LIIII
ToRomanNumeral(54, str, .subtractive = true);
printf(str); // LIV
}
Numbers
Contrary to popular belief, there is no fixed standard on how to write certain numbers. These are all valid versions of 449:
CCCCXXXXVIIII
CCCCXLVIIII
CDXXXXVIIII
CCCCXXXXIX
CDXLVIIII
CDXXXXIX
CCCCXLIX
CDXLVIII
CCCCIL
CDIL
Normally it is only 4 and 9 that has this ambiguity, so this library handles every variant of those. There is some evidence that any number can use this scheme, so 8 could be IIX, but these extra extended numbers are not yet handled. Unsurprisingly, Tom Scott has a relevant video:
https://www.youtube.com/watch?v=jMxoGqsmk5Y
There is also no standard for numbers over 3000, since there is no symbol for 5000. Two methods are to simply use more Ms, or to add a bar over numbers indicating * 1000. This library uses the former, up to pawn symbol limits (31 characters). Thus the largest possible number you can represent without modifying the compiler is in unprefixed mode and is 31000 (MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM).
Testing
To test, simply run the package:
sampctl package run
Diese Seite wird aus dem erstellt, was GitHub über das Repository veröffentlicht. samp.directory hostet den Code nicht. Ein Problem mit diesem Eintrag melden