forked from persian-tools/go-persian-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
digit
Amir Iranmanesh edited this page Aug 11, 2026
·
2 revisions
Format numbers with thousands separators and convert digits to Persian words.
import "github.com/amiranmanesh/go-persian-tools/digit"Accepts Persian or ASCII digits, optionally negative. Returns an empty string on invalid input.
digit.DigitToWord("۱۵۶۷۸۹") // "صد پنجاه و شش هزار هفتصد هشتاد و نه"
digit.DigitToWord("156789") // "صد پنجاه و شش هزار هفتصد هشتاد و نه"
digit.DigitToWord("-10") // "منفی ده"digit.AddCommas(14555478854) // "14,555,478,854"
n, err := digit.RemoveCommas("4,555,478,854") // 4555478854 (int64), nil
if err != nil {
// input was not a valid integer
}
RemoveCommasreturns(int64, error)— it will not overflow on large values and reports parse errors instead of silently returning0.
Packages
Project