MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / xlate_ordinal

Function xlate_ordinal

extlibs/soloud/src/audiosource/speech/tts.cpp:727–835  ·  view source on GitHub ↗

** Translate a number to phonemes. This version is for ORDINAL numbers. ** Note: this is recursive. */

Source from the content-addressed store, hash-verified

725** Note: this is recursive.
726*/
727static int xlate_ordinal(int value, darray *phone)
728{
729 int nph = 0;
730
731 if (value < 0)
732 {
733 nph += xlate_string("minus", phone);
734 value = (-value);
735
736 if (value < 0) /* Overflow! -32768 */
737 {
738 nph += xlate_string("a lot", phone);
739 return nph;
740 }
741 }
742
743 if (value >= 1000000000L)
744 /* Billions */
745 {
746 nph += xlate_cardinal(value / 1000000000L, phone);
747 value = value % 1000000000;
748
749 if (value == 0)
750 {
751 nph += xlate_string("billionth", phone);
752 return nph; /* Even billion */
753 }
754
755 nph += xlate_string("billion", phone);
756
757 if (value < 100)
758 nph += xlate_string("and", phone);
759
760 /* as in THREE BILLION AND FIVE */
761 }
762
763 if (value >= 1000000L)
764 /* Millions */
765 {
766 nph += xlate_cardinal(value / 1000000L, phone);
767 value = value % 1000000L;
768
769 if (value == 0)
770 {
771 nph += xlate_string("millionth", phone);
772 return nph; /* Even million */
773 }
774
775 nph += xlate_string("million", phone);
776
777 if (value < 100)
778 nph += xlate_string("and", phone);
779
780 /* as in THREE MILLION AND FIVE */
781 }
782
783 /* Thousands 1000..1099 2000..99999 */
784 /* 1100 to 1999 is eleven-hunderd to ninteen-hunderd */

Callers

nothing calls this directly

Calls 2

xlate_stringFunction · 0.85
xlate_cardinalFunction · 0.85

Tested by

no test coverage detected