{"record":{"id":"e3569201283e3172","repo":"TheAlgorithms/Java","slug":"missing-decimal-numbers","errorCode":"MISSING_DECIMAL_NUMBERS","errorMessage":"Invalid Input. Decimal part is missing numbers.","messagePattern":"Invalid Input\\. Decimal part is missing numbers\\.","errorType":"exception","errorClass":"WordsToNumberException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/thealgorithms/conversions/WordsToNumber.java","lineNumber":294,"sourceCode":"                    int numberDigitCount = number.toString().length();\n                    return chunkDigitCount > numberDigitCount;\n                }\n\n                private static String convertDecimalPart(ArrayDeque<String> wordDeque) {\n                    StringBuilder decimalPart = new StringBuilder(\".\");\n\n                    while (!wordDeque.isEmpty()) {\n                        String word = wordDeque.poll();\n                        Integer number = NumberWord.getValue(word);\n                        if (number == null) {\n                            throw new WordsToNumberException(WordsToNumberException.ErrorType.UNEXPECTED_WORD_AFTER_POINT, word);\n                        }\n                        decimalPart.append(number);\n                    }\n\n                    boolean missingNumbers = decimalPart.length() == 1;\n                    if (missingNumbers) {\n                        throw new WordsToNumberException(WordsToNumberException.ErrorType.MISSING_DECIMAL_NUMBERS, \"\");\n                    }\n                    return decimalPart.toString();\n                }\n\n                private static BigDecimal combineChunks(List<BigDecimal> chunks) {\n                    BigDecimal completeNumber = BigDecimal.ZERO;\n                    for (BigDecimal chunk : chunks) {\n                        completeNumber = completeNumber.add(chunk);\n                    }\n                    return completeNumber;\n                }\n        }\n\n        class WordsToNumberException extends RuntimeException {\n\n                @Serial private static final long serialVersionUID = 1L;\n\n                enum ErrorType {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/TheAlgorithms/Java/blob/fdfb9a395b310167a66bd29e311e36e0e3e9b964/src/main/java/com/thealgorithms/conversions/WordsToNumber.java#L276-L312","documentation":"Thrown in convertDecimalPart when the word 'point' is not followed by any number words — the decimal StringBuilder remains at length 1 (just '.'). This means 'point' was the last token in the input with nothing after it.","triggerScenarios":"convert('one point'), convert('five point '), convert('negative ten point'). Any input ending with 'point' and no subsequent digit words.","commonSituations":"Truncated input; copy-paste that drops trailing words; voice input cutoff; programmatic phrase construction that omits the decimal digits.","solutions":["Ensure 'point' is always followed by at least one single-digit number word.","Trim trailing 'point' from input if it is spurious.","Validate that 'point' is not the final token before calling convert."],"exampleFix":"// before\nWordsToNumber.convert('one point');\n// after\nWordsToNumber.convert('one point five'); // 1.5","handlingStrategy":"validation","validationCode":"static String ensureDecimalFollowed(String s) {\n    String[] words = s.trim().toLowerCase(Locale.ROOT).split(\"[ ,-]+\");\n    if (words.length > 0 && \"point\".equals(words[words.length - 1])) {\n        throw new IllegalArgumentException(\"'point' must be followed by digit words\");\n    }\n    return s;\n}","typeGuard":null,"tryCatchPattern":"try { WordsToNumber.convert(input); } catch (WordsToNumberException e) {\n    if (e.errorType == ErrorType.MISSING_DECIMAL_NUMBERS) throw new ApiException(400, \"'point' must be followed by at least one digit word\");\n    throw e;\n}","preventionTips":["Always follow 'point' with at least one single-digit word.","Trim trailing 'point' if it is spurious.","Validate that 'point' is not the final token."],"tags":["java","words-to-number","grammar","decimal"],"backgroundTag":null,"analyzedSha":"fdfb9a395b310167a66bd29e311e36e0e3e9b964","analyzedAt":"2026-08-13T23:36:13.315Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}