You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
635 B

  1. // Copyright 2017 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package number_test
  5. import (
  6. "golang.org/x/text/language"
  7. "golang.org/x/text/message"
  8. "golang.org/x/text/number"
  9. )
  10. func ExampleMaxIntegerDigits() {
  11. const year = 1999
  12. p := message.NewPrinter(language.English)
  13. p.Println("Year:", number.Decimal(year, number.MaxIntegerDigits(2)))
  14. // Output:
  15. // Year: 99
  16. }
  17. func ExampleIncrementString() {
  18. p := message.NewPrinter(language.English)
  19. p.Println(number.Decimal(1.33, number.IncrementString("0.50")))
  20. // Output: 1.50
  21. }