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

Function xlate_cardinal

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

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

Source from the content-addressed store, hash-verified

631** Note: this is recursive.
632*/
633static int xlate_cardinal(int value, darray *phone)
634{
635 int nph = 0;
636
637 if (value < 0)
638 {
639 nph += xlate_string("minus", phone);
640 value = (-value);
641
642 if (value < 0) /* Overflow! -32768 */
643 {
644 nph += xlate_string("a lot", phone);
645 return nph;
646 }
647 }
648
649 if (value >= 1000000000L)
650 /* Billions */
651 {
652 nph += xlate_cardinal(value / 1000000000L, phone);
653 nph += xlate_string("billion", phone);
654 value = value % 1000000000;
655
656 if (value == 0)
657 return nph; /* Even billion */
658
659 if (value < 100)
660 nph += xlate_string("and", phone);
661
662 /* as in THREE BILLION AND FIVE */
663 }
664
665 if (value >= 1000000L)
666 /* Millions */
667 {
668 nph += xlate_cardinal(value / 1000000L, phone);
669 nph += xlate_string("million", phone);
670 value = value % 1000000L;
671
672 if (value == 0)
673 return nph; /* Even million */
674
675 if (value < 100)
676 nph += xlate_string("and", phone);
677
678 /* as in THREE MILLION AND FIVE */
679 }
680
681 /* Thousands 1000..1099 2000..99999 */
682 /* 1100 to 1999 is eleven-hunderd to ninteen-hunderd */
683
684 if ((value >= 1000L && value <= 1099L) || value >= 2000L)
685 {
686 nph += xlate_cardinal(value / 1000L, phone);
687 nph += xlate_string("thousand", phone);
688 value = value % 1000L;
689
690 if (value == 0)

Callers 2

xlate_ordinalFunction · 0.85
xlate_stringFunction · 0.85

Calls 1

xlate_stringFunction · 0.85

Tested by

no test coverage detected