Code Monkey home page Code Monkey logo

indianmoney's Introduction

indianmoney

This golang library used to format number in Indian money type. Displaying Currency in Indian Numbering Format.

Quick Start

go get github.com/punithck/indianmoney

** Examples **

0---> 0
1---> 1
12---> 12
123---> 123
1234---> 1,234
12345---> 12,345
123456---> 1,23,456
1234567---> 12,34,567
12345678---> 1,23,45,678
-123456789---> -12,34,56,789
1234567899---> 1,23,45,67,899
-12345678999---> -12,34,56,78,999
123456789999---> 1,23,45,67,89,999
0.0---> 0.00
1.1---> 1.10
12.12---> 12.12
123.123---> 123.123
1234.123---> 1,234.1230
12345.1234---> 12,345.12345
123456.12345---> 1,23,456.12345
1234567.12345---> 12,34,567.12
-12345678.123456---> -1,23,45,678.123
123456789.123456---> 12,34,56,789.12
-1234567899.123456---> -1,23,45,67,899.123456
12345678999.123456---> 12,34,56,78,999.123455
123456789999.123456---> 1,23,45,67,89,999.123459

example.go

package main

import (
	"fmt"

	"github.com/punithck/indianmoney"
)

func main() {
	//Integer value formatting
	fmt.Println("0--->", indianmoney.FormatMoneyInt(0))
	fmt.Println("1--->", indianmoney.FormatMoneyInt(1))
	fmt.Println("12--->", indianmoney.FormatMoneyInt(12))
	fmt.Println("123--->", indianmoney.FormatMoneyInt(123))
	fmt.Println("1234--->", indianmoney.FormatMoneyInt(1234))
	fmt.Println("12345--->", indianmoney.FormatMoneyInt(12345))
	fmt.Println("123456--->", indianmoney.FormatMoneyInt(123456))
	fmt.Println("1234567--->", indianmoney.FormatMoneyInt(1234567))
	fmt.Println("12345678--->", indianmoney.FormatMoneyInt(12345678))
	fmt.Println("-123456789--->", indianmoney.FormatMoneyInt(-123456789))
	fmt.Println("1234567899--->", indianmoney.FormatMoneyInt(1234567899))
	fmt.Println("-12345678999--->", indianmoney.FormatMoneyInt(-12345678999))
	fmt.Println("123456789999--->", indianmoney.FormatMoneyInt(123456789999))

	//Float value formatting
	fmt.Println("0.0--->", indianmoney.FormatMoneyFloat64(0.0, 2))
	fmt.Println("1.1--->", indianmoney.FormatMoneyFloat64(1.1, 2))
	fmt.Println("12.12--->", indianmoney.FormatMoneyFloat64(12.12, 2))
	fmt.Println("123.123--->", indianmoney.FormatMoneyFloat64(123.123, 3))
	fmt.Println("1234.123--->", indianmoney.FormatMoneyFloat64(1234.123, 4))
	fmt.Println("12345.1234--->", indianmoney.FormatMoneyFloat64(12345.12345, 5))
	fmt.Println("123456.12345--->", indianmoney.FormatMoneyFloat64(123456.12345, 5))
	fmt.Println("1234567.12345--->", indianmoney.FormatMoneyFloat64(1234567.123456, 2))
	fmt.Println("-12345678.123456--->", indianmoney.FormatMoneyFloat64(-12345678.123456, 3))
	fmt.Println("123456789.123456--->", indianmoney.FormatMoneyFloat64(123456789.123456, 2))
	fmt.Println("-1234567899.123456--->", indianmoney.FormatMoneyFloat64(-1234567899.123456, 6))
	fmt.Println("12345678999.123456--->", indianmoney.FormatMoneyFloat64(12345678999.123456, 6))
	fmt.Println("123456789999.123456--->", indianmoney.FormatMoneyFloat64(123456789999.123456, 6))
}

To format int to INR type

indianmoney.FormatMoneyInt(12345) or
indianmoney.FormatMoneyInt64(12345)

To format float64 to INR type

indianmoney.FormatMoneyFloat64(12345.12345, 5) //max_precision_supported  = 6

indianmoney's People

Contributors

punithck avatar

Stargazers

Sushant Kumar avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.