Questions tagged [numbers-to-words]

Converting numbers to their English representation is a common programming challenge where the goal is to take a number as input and output it's English equivalent. For example: input 1024; output "One Thousand Twenty-Four".

Filter by
Sorted by
Tagged with
40 votes
6 answers
3k views

SHOUTY_SNAKE_CASED NUMBERS

WE_ALL_LOVE_SHOUTY_SNAKE_CASE_SO_I_WROTE_A_PROGRAM_FOR_IT!!1! Alright, enough of this. This is a rags-to-riches from this question. The pattern is pretty simple, it takes a ...
IEatBagels's user avatar
  • 12.4k
26 votes
5 answers
6k views

Japanese reading of an integer

Inspired by CtCI 16.8: Integer to English phrase in C++, I wrote a program to show the Japanese reading of an integer (positive, negative, or zero). The Japanese is written in Hepburn romanization to ...
L. F.'s user avatar
  • 9,456
19 votes
4 answers
10k views

Converting a large number into something like: 4 Novemnongent

This is not a school project, just something to help me learn some Python! Just looking to see what I can improve on, looking for tips to reduce size & make it a bit easier for the computer to run ...
user155845's user avatar
17 votes
3 answers
10k views

Converting numbers to words - Python

I'm new to programming. I tried to find a way to convert numbers into letters with Python. I would like to receive some advice to improve myself. This program works for numbers between 1 and 106 and ...
Roberta Belladonna's user avatar
15 votes
4 answers
3k views

Int extension for translating integer to plain English

This code was inspired by this question: Number to Words ...
nhgrif's user avatar
  • 25.2k
15 votes
4 answers
2k views

Number to words in left to right direction

I have faced this question in an interview: If we enter a number it will convert into individual strings and display in same order. Ex: If I enter 564 then the ...
user3667402's user avatar
15 votes
2 answers
273 views

One, two, three, … Un, deux, trois, …, maxBound::Int

I wrote a numbers-to-words converter for English, then tried to adapt the code to work for French. I'm wondering mainly whether any simplifications are possible. In English English is relatively ...
200_success's user avatar
13 votes
2 answers
2k views

Create the English word for a number

I cobbled together a function from various sources that takes an integer and returns it as its respective English word formatted as a string. The function is as follows: ...
James Draper's user avatar
13 votes
2 answers
30k views

Changing Number to Words in JavaScript

One day I saw a question on Stack Overflow asking about changing numbers to words, I thought about it, and next day I started coding. When I had the code working, I thought it could, most likely, be ...
bpbutti's user avatar
  • 233
13 votes
1 answer
297 views

Naming numbers in American English

This seems like a popular topic lately, so I took a crack at it. Related questions are Number to Words and Converting a number to the text representation. I used this article as a guideline. The ...
Dagg's user avatar
  • 4,531
12 votes
1 answer
389 views

Convert any number (up to 10^3000) to text

I kinda got the idea after playing Adventure Capitalist, since that goes up to 10300. I found a website that explained how to go up to 10^3000, so I mainly did this as a challenge to see if I could do ...
Peter's user avatar
  • 1,125
10 votes
2 answers
940 views

Numbers to words converter

Please review my code: ...
Sajal Arora's user avatar
10 votes
2 answers
1k views

Number to English word converter

This is a simple program that I wrote. It takes a 64-bit unsigned int as input and returns its English name. ...
Teodor Dyakov's user avatar
10 votes
2 answers
2k views

Number to Words

I have to convert positive numbers, that are less than 1000, to words. A quick search didn't find anything that looked good to my eye, so I came up with the following. While I was at it I expanded ...
dbasnett's user avatar
  • 371
9 votes
4 answers
1k views

Simple Number to Words using a Single Loop String Triplets in JavaScript

I have extensively reviewed 2 old articles on the subject: https://stackoverflow.com/questions/14766951/convert-digits-into-words-with-javascript and https://stackoverflow.com/questions/5529934/...
Mohsen Alyafei's user avatar
9 votes
1 answer
923 views

Number in words: recursive function

I would appreciate some feedback on the below code I wrote for a Project Euler problem. The answer comes out correct but I'd like feedback on the design of the function and implementation of ...
engineer.larry's user avatar
9 votes
3 answers
22k views

Number-to-word converter

My code works, but the aesthetic of the code seems to need some real work. The logic is simple enough: Create three lists of words that will be used throughout the conversion Create three functions: ...
WGS's user avatar
  • 193
8 votes
3 answers
7k views

Converting a number to the text representation

Following along with some previous questions: The @dbasnett original here: Number to Words @nhgrif's here: Int extension for translating integer to plain English I wanted to answer the original ...
rolfl's user avatar
  • 97.3k
8 votes
3 answers
3k views

Integers to English words in C

As a beginner in C programming, I decided to write a function words that, given an unsigned integer n, puts the English ...
hjkl's user avatar
  • 123
8 votes
2 answers
14k views

Digit to words converter

This is one of the longest programs I have made with methods and I think I must be doing this rather inefficiently. Any comments to improve would be appreciated. ...
lukeb28's user avatar
  • 445
8 votes
1 answer
2k views

Code to convert number to words

I am trying to practice objects and functions (specifically closures & higher order functions) in javascript. There is no specific reason why I chose this program but it struck my mind to work out ...
Harish's user avatar
  • 181
8 votes
1 answer
3k views

Dividing a number half into words and half number

Example: If I have a number 1000: I first put commas (In English Standard) that makes it: 1,000 I split the above at the first comma: I get 1 I convert 1 into words: I get One, name it ...
User3's user avatar
  • 261
7 votes
4 answers
37k views

Converting number to words

First it asks for user to input a number and it will convert it into words. For example: 104382426112 to ...
Sagar Devkota's user avatar
7 votes
2 answers
1k views

Convert numbers into a textual form

So this was originally inspired by @nhgrif's Int extension for translating integer to plain English, however the code is mainly a port of @rolfl's Converting a number to the text representation; ...
syb0rg's user avatar
  • 21.8k
7 votes
5 answers
70k views

Convert number to words

I wrote this converter code. It can convert a number from 1-100 into words. It works perfectly, but it seems to be too complicated to me. Can you tell me whether it's okay or not? ...
mitya221's user avatar
  • 793
7 votes
2 answers
14k views

Converting an integer number into its word representation

I've written this code to convert an integer number into its word representation. I've tested it for many cases and it seems to be working as expected. For example: 1000 displayed as "One Thousand" ...
Phoenix's user avatar
  • 353
7 votes
2 answers
2k views

Number to spanish word converter

This converts from a number to a Spanish word for example : 100 => cien 200 => doscientos I used a divide-and-conquer approach: Constants: ...
MAG's user avatar
  • 2,954
7 votes
1 answer
3k views

Converting numbers to words in Haskell

Here's a program I wrote to convert numbers into English words using Haskell. ...
BrainFRZ's user avatar
  • 819
7 votes
1 answer
252 views

CtCI 16.8: Integer to English phrase in C++

I'm a C++ beginner working through Cracking the Coding Interview. This is question 16.8: Given any integer, print an English phrase that describes the integer (e.g., "One Thou­sand, Two Hundred ...
Undo's user avatar
  • 790
6 votes
2 answers
2k views

Convert number into words

I am trying to implement a program which can convert number into words. My code can convert numbers between 0 - 999. It uses recursive function calls and simple arithmetic operations. Can you please ...
Mo Moallim's user avatar
6 votes
1 answer
1k views

Convert time 24hr format into time as words

I'm currently writing a Scala Object that converts time 24hr format (i.e. 00:00 - 23:59) into Time As Words (i.e. Eight o'clock, Half past eight, Quarter to nine etc). How can I refactor the current ...
Peter Wilson's user avatar
6 votes
2 answers
7k views

Writing the word equivalent of a check (cheque) amount

I am looking for feedback on a solution to the following problem posed from a book that I'm working through (Java: How To Program 9th Edition): Continuing the discussion in Exercise 16.20, we ...
cryptocurry's user avatar
6 votes
4 answers
276 views

Converts number in text format function code

I have created a function which converts numbers into text format and successfully converted up to 6 digit numbers. However, I want to know if I can make any modifications to make the code shorter. ...
Gaurav Aggarwal's user avatar
6 votes
3 answers
600 views

Very Simple Spell (Number to Words) 001 to 999 in VBA

I have come across many spell number functions and have reviewed many VBA code available on the net. The core function that gets called repeatedly is the function that converts numbers from 001 to ...
Mohsen Alyafei's user avatar
6 votes
2 answers
2k views

Number to words in Python 3

Here is a sample program I have written to convert numbers to words: ...
internet_user's user avatar
6 votes
1 answer
3k views

Convert a number to text

This converts a "numerical number" to a text representation, for example: convert 1234 --> "One Thousand, Two Hundred Thirty Four" I'd like general feedback on how it could be make more readable ...
Carcigenicate's user avatar
5 votes
4 answers
2k views

Converting int values in Java to human readable strings in English

(See also the next iteration.) I have rolled this short program that converts int values to the human readable strings: ...
coderodde's user avatar
  • 27k
5 votes
4 answers
2k views

Spelling a number in English

My Implementation: ...
Rezo Megrelidze's user avatar
5 votes
3 answers
2k views

Number to words problem

This is a very long solution I've been working on to a Number to Words problem. I've identified that there's a lot of repeating logic (e.g. 'if writing > 0', 'writing = integer /',). How would you ...
user avatar
5 votes
1 answer
396 views

Number to Text converter in Haskell

I've written this code in Haskell to convert a number into its written form. It feels ok but at the same time I feel like it can probably be improved on a lot. I would appreciate help in improving it. ...
noatbfgtxa's user avatar
5 votes
2 answers
220 views

Integer to English challenge

I have a challenge, which is to create a JavaScript function that turns a given number into the string representation. For example: console.log(inToEnglish(15)) ...
Flame_Phoenix's user avatar
5 votes
1 answer
1k views

Putting numbers into words

I have some embarrassingly long code which puts into words any number up into the trillions. As a newbie, and understanding that shorter, non-repetitive code is best, I am looking for suggestions on ...
HolyMoly's user avatar
  • 149
5 votes
2 answers
2k views

Numbers to Text Program - Python Training

I have written a numbers to text challenge for some people in my organisation to practice their Python skills. I am an economist working with pandas, but I am trying to teach them some stuff about ...
Woody Pride's user avatar
5 votes
1 answer
2k views

Project Euler no. 17: Counting letters to write the numbers from 1 to 1000

I'm very new to programming and am admittedly embarrassed sharing my code for critique. This code works and produces the correct answer to the Project Euler Problem 17, which asks how many letters ...
Jai Kamat's user avatar
4 votes
4 answers
2k views

Project Euler 17: counting letters needed to write numbers

The statement of the problem is : If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers ...
Mayur Kulkarni's user avatar
4 votes
3 answers
200 views

Converting numbers to text

This code seems to work fine but I am sure this reads very amateurish. I would appreciate your comments as to how to make this code more "professional": ...
Areng's user avatar
  • 43
4 votes
2 answers
197 views

Simple Number to Words using a Single Loop String Triplets in VBA

As an update (conversion) to my article “Simple Number to Words using a Single Loop String Triplets in JavaScript” in JavaScript, I have converted the code to work as a VBA function using the same ...
Mohsen Alyafei's user avatar
4 votes
3 answers
988 views

Number to word converter (1 to 99 inclusive)

Program It takes a numerical input in range [1, 99] and outputs its word equivalent. Concerns Procedural approach General code style Code ...
alienCY's user avatar
  • 363
4 votes
1 answer
129 views

Measuring the length of binary numbers in English words in C

Inspired by this question (link to original video), I decided to write some code in C to perform this task, and it is much faster than the Python code, even when run with PyPY, up to a billion, it ...
Caridorc's user avatar
  • 27.4k
4 votes
1 answer
374 views

Print and calculate French written numbers from 1 to 1000 using imperative Java

I've written a little (imperative) java program that basically prints out all french written numbers from 1 to 1000. (I'm learning how to write them) Based on the first numbers (1-16) and the tens ...
toogley's user avatar
  • 193