[ad_1]
Hi;
Any chance we can read a number? I actually wrote some code but it’s typing some numbers wrong.
I wrote the code like this.
But :15000000 “ten five million” writes as. Actually fifteen million
if (fieldname19 === 'B') {
var ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
var tens = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
var scales = ['', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion'];
var number = fieldname17;
if (number == 0) {
reading = 'zero';
} else {
var numberStr = String(number);
var groupCount = Math.ceil(numberStr.length / 3);
for (var i = 0; i < groupCount; i++) {
var scaleValue = Number(numberStr.slice(-3));
numberStr = numberStr.slice(0, -3).trim();
if (scaleValue !== 0 || i === 0) {
var scaleReading = '';
var hundredsDigit = Math.floor(scaleValue / 100);
var tensDigit = Math.floor((scaleValue % 100) / 10);
var onesDigit = scaleValue % 10;
if (hundredsDigit !== 0) {
if (hundredsDigit === 1) {
scaleReading += 'one hundred ';
} else {
scaleReading += ones[hundredsDigit] + ' hundred ';
}
}
if (tensDigit !== 0) {
if (tensDigit === 1 && onesDigit !== 0) {
scaleReading += 'ten ' + ones[onesDigit];
} else {
scaleReading += tens[tensDigit];
if (onesDigit !== 0) {
scaleReading += ' ' + ones[onesDigit];
}
}
} else if (onesDigit !== 0) {
scaleReading += ones[onesDigit];
}
if (reading !== '') {
scaleReading += ' ';
}
scaleReading += scales[i] + ' ';
reading = scaleReading + reading;
}
}
}
}
