currency
Is there a way to round numbers into a reader friendly format? (e.g. $1.1k) [closed]
Here is a simple function to do it: function abbrNum(number, decPlaces) { // 2 decimal places => 100, 3 => 1000, etc decPlaces = Math.pow(10, decPlaces); // Enumerate number abbreviations var abbrev = [“k”, “m”, “b”, “t”]; // Go through the array backwards, so we do the largest first for (var i = abbrev.length – …
Regex currency validation
The RegEx // Requires a decimal and commas ^\$?(([1-9]\d{0,2}(,\d{3})*)|0)?\.\d{1,2}$ // Allows a decimal, requires commas (?=.*\d)^\$?(([1-9]\d{0,2}(,\d{3})*)|0)?(\.\d{1,2})?$ // Decimal and commas optional (?=.*?\d)^\$?(([1-9]\d{0,2}(,\d{3})*)|\d+)?(\.\d{1,2})?$ // Decimals required, commas optional ^\$?(([1-9]\d{0,2}(,\d{3})*)|0)?\.\d{1,2}$ // *Requires/allows X here also implies “used correctly” The RegEx Breakdown When the optional parts are too liberal, we need to look ahead and guarantee there’s a …
Get currency symbols from currency code with swift
A bit late but this is a solution I used to get the $ instead of US$ etc. for currency symbol. /* * Bear in mind not every currency have a corresponding symbol. * * EXAMPLE TABLE * * currency code | Country & Currency | Currency Symbol * * BGN | Bulgarian lev | …
Javascript number.toLocaleString currency without currency sign
There is no way to pass parameter to toLocaleString and remove currency symbol. so use this function instead. var convertedNumber = num.toLocaleString(‘de-DE’, { minimumFractionDigits: 2 });
Get the currency format for a country that does not have a Locale constant
According to the JDK release notes, you have locale codes hi_IN (Hindi) and en_IN (English). System.out.println(Currency.getInstance(new Locale(“hi”, “IN”)).getSymbol());
Rounding integers to nearest multiple of 10 [duplicate]
I would just create a couple methods; int RoundUp(int toRound) { if (toRound % 10 == 0) return toRound; return (10 – toRound % 10) + toRound; } int RoundDown(int toRound) { return toRound – toRound % 10; } Modulus gives us the remainder, in the case of rounding up 10 – r takes you …
How to display the currency symbol to the right in Angular
Since Angular2 RC6 version you can set default locale directly in your app module (providers): import {NgModule, LOCALE_ID} from ‘@angular/core’; @NgModule({ providers: [{ provide: LOCALE_ID, useValue: ‘de-DE’ // ‘de-DE’ for Germany, ‘fr-FR’ for France … }, ] }) Afterwards the currency pipe should pick up the locale settings and move the symbol to right: @Component({ …
Is there a functionality in JavaScript to convert values into specific locale formats?
I found a way to do this at this page. You can you toLocaleString without using toFixed before it. toFixed returns a string, toLocaleString should get a number. But you can pass an options object with toLocaleString, the option minimumFractionDigits could help you with the functionality toFixed has. 50.toLocaleString(‘de-DE’, { style: ‘currency’, currency: ‘EUR’, minimumFractionDigits: …