Source File
number.go
Belonging Package
golang.org/x/text/number
// Copyright 2017 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package number// TODO:// p.Printf("The gauge was at %v.", number.Spell(number.Percent(23)))// // Prints: The gauge was at twenty-three percent.//// p.Printf("From here to %v!", number.Spell(math.Inf()))// // Prints: From here to infinity!//import ()const (decimalVerbs = "vfgd"scientificVerbs = "veg")// Decimal formats a number as a floating point decimal.func ( interface{}, ...Option) Formatter {return newFormatter(decimalOptions, , )}var decimalOptions = newOptions(decimalVerbs, (*number.Formatter).InitDecimal)// Scientific formats a number in scientific format.func ( interface{}, ...Option) Formatter {return newFormatter(scientificOptions, , )}var scientificOptions = newOptions(scientificVerbs, (*number.Formatter).InitScientific)// Engineering formats a number using engineering notation, which is like// scientific notation, but with the exponent normalized to multiples of 3.func ( interface{}, ...Option) Formatter {return newFormatter(engineeringOptions, , )}var engineeringOptions = newOptions(scientificVerbs, (*number.Formatter).InitEngineering)// Percent formats a number as a percentage. A value of 1.0 means 100%.func ( interface{}, ...Option) Formatter {return newFormatter(percentOptions, , )}var percentOptions = newOptions(decimalVerbs, (*number.Formatter).InitPercent)// PerMille formats a number as a per mille indication. A value of 1.0 means// 1000‰.func ( interface{}, ...Option) Formatter {return newFormatter(perMilleOptions, , )}var perMilleOptions = newOptions(decimalVerbs, (*number.Formatter).InitPerMille)// TODO:// - Shortest: akin to verb 'g' of 'G'//// TODO: RBNF forms:// - Compact: 1M 3.5T// - CompactBinary: 1Mi 3.5Ti// - Long: 1 million// - Ordinal:// - Roman: MCMIIXX// - RomanSmall: mcmiixx// - Text: numbers as it typically appears in running text, allowing// language-specific choices for when to use numbers and when to use words.// - Spell?: spelled-out number. Maybe just allow as an option?// NOTE: both spelled-out numbers and ordinals, to render correctly, need// detailed linguistic information from the translated string into which they// are substituted. We will need to implement that first.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |