Latest 0.1
Homepage https://github.com/FriendlyU/FriendlyNumbers
License MIT
Platforms ios 8.0
Authors

Converts numbers like 1000 to 1K and 1500 to 1.5K.

This representation of numbers using K (thousand), M (million), and B (billion) is commonly used in banking and games universe to simplify the reading of a big number.

Installation

FriendlyNumbers is available through CocoaPods.

To install it, simply add the following line to your Podfile:

pod 'FriendlyNumbers'

Usage

There are two different features available. FNSimple and FNMostSimple. Both can be used directly onto an integer.

FNSimple rounds numbers to the nearest tenths place whereas FNMostSimple rounds numbers to the nearest whole number.

Examples

let number = 1530
print(number.FNMostSimple) // prints 1K

let number = 1530
print(number.FNSimple) // prints 1.5K

let number = 15320
print(number.FNMostSimple) // prints 15K

let number = 15320
print(number.FNSimple) // prints 15.3K

let number = 153200
print(number.FNMostSimple) // prints 153K

let number = 153200
print(number.FNSimple) // prints 153.2K

let number = 1532200
print(number.FNMostSimple) // prints 1M

let number = 1532200
print(number.FNSimple) // prints 1.5M

let number = 15300000
print(number.FNMostSimple) // prints 15M

let number = 15300000
print(number.FNSimple) // prints 15.3M

Latest podspec

{
    "name": "FriendlyNumbers",
    "version": "0.1",
    "summary": "Making numbers friendlier.",
    "description": "Converts number like 1000 to 1K and 1500 to 1.5K.",
    "homepage": "https://github.com/FriendlyU/FriendlyNumbers",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Henry Saniuk": "[email protected]"
    },
    "source": {
        "git": "https://github.com/FriendlyU/FriendlyNumbers.git",
        "tag": "0.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Sources/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This