num2words

package module
v0.0.0-...-57dba45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2017 License: MIT Imports: 1 Imported by: 21

README

num2words

Build Status GoDoc

num2words - Numbers to words converter in Go (Golang)

Usage

First, import package num2words

import github.com/divan/num2words

Convert number

  str := num2words.Convert(17) // outputs "seventeen"
  ...
  str := num2words.Convert(1024) // outputs "one thousand twenty four"
  ...
  str := num2words.Convert(-123) // outputs "minus one hundred twenty three"

Convert number with " and " between number groups:

  str := num2words.ConvertAnd(514) // outputs "five hundred and fourteen"
  ...
  str := num2words.ConvertAnd(123) // outputs "one hundred and twenty three"

Documentation

Overview

Package num2words implements numbers to words converter.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(number int) string

Convert converts number into the words representation.

Example
fmt.Println(num2words.Convert(11))
fmt.Println(num2words.Convert(123))
fmt.Println(num2words.Convert(-99))
Output:

eleven
one hundred twenty-three
minus ninety-nine

func ConvertAnd

func ConvertAnd(number int) string

ConvertAnd converts number into the words representation with " and " added between number groups.

Example
fmt.Println(num2words.ConvertAnd(123))
fmt.Println(num2words.ConvertAnd(514))
Output:

one hundred and twenty-three
five hundred and fourteen

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL