I use the KendoUI nummeric control like this:
#(Html.Kendo().NumericTextBoxFor(o => o.Price)
.Culture("nl-NL")
.Format("c")
.Decimals(0)
.Spinners(false)
.Min(0)
.Max(50000000)
.HtmlAttributes(new { Style = "width: 300px;" }))
In the textarea i get this result: $87,845.00
I would like to have my result like this: € 87 845 or 87 845 €
The strange part is that i set decimals to 0 and i get 2 digits after the .
Anyone ?
Currently i have a work around and i set the formtat to "0 €" and i get this 87845 €
(There is no space after 3 digits)
Several questions:
Decimals affect only edition mode. Saying Decimals(1) allows you to enter 1 decimal, saying 0, does not allow you to enter decimals.
For controlling the display once edited you should use Format("c0")
About not getting the €, it seems to me that you are not including js/cultures/kendo.culture.nl-NL.min.js file, is that possible?
Related
I have cells and each contains these text :
my_col_10x50_new
my_col_20x40_new
my_col_30x30_new
my_col_15x50_new
I want correspondingly to extract just the number parts and make a "xx and xx" format like these :
10 and 50
20 and 40
30 and 30
15 and 50
Anyone can help ?
You can try a combination of substitute and regex extract:
=SUBSTITUTE(REGEXEXTRACT(A1, "[0-9]+x[0-9]+"),"x", " and ")
The REGEXEXTRACT extracts the numbers along with the x in the middle and substitute replaces the x with the 'and' in the middle keeping the numbers as is.
use:
=INDEX(IFNA(REGEXREPLACE(REGEXEXTRACT(A1:A, "\d+x\d+"), "x", " and ")))
Another option:
=INDEX(SPLIT(SUBSTITUTE(A1:A,"x"," and "),"_"),0,3)
I'm working on an app that shows currencies with large numbers.
To make it more user friendly it would be nice to show the numbers with letters, e.g:
$24,514,983,671 -> $24.5B // English
3,306,777.10 € -> 3,31 Mio. € // German
kr 23 000 000 -> kr 23 mill. // Norwegian
The numbers should have minimumSignificantDigits = 1 and maximumSignificantDigits = 3.
How should this be solved in Swift? Is there any library available?
Android has this solution
It seems to be based on swift-corelibs-foundation: Github, but I can't see how to use it in my app.
Will I have to make the logic myself with localized translations?
I have found an answer for using general abbreviations K/M/B for large numbers here: iOS convert large numbers to smaller format, but it does not solve the whole problem.
You will have to implement your own solution, but it is not hard. One way to go would be to create two dictionaries where the key will be the Locale identifier and the value the translation:
let millionTrans = [ "en_US" : "million", ...]
let billionTrans = [ "en_US': "billion", ...]
then get the Locale.current, find out if the amount is in the millions or billions and query the appropriate dictionary to get its value.
I'm building a calculator like. Every time I press one of the number buttons of the calculator, I would like to have the label displaying the input, to concatenate the new input to the display.
Let's say I press 1 then 2 then 5 and the label displays 125. So far I was converting each number into a string and was appending them one after one. But I would like to make it "localized". So that if the locale is US, for 1,256.43 it display 1,256.43. If the locale is FR, it displays 1 256,43.
For that I was doing the same than before but to convert the number to string I was using a NSNumberFormatter. The problem is when I get the string 1 256 and I convert it into double (to then use the formatter) with NSString(string: "1 256").doubleValue I get 1 and not 1 256
What do I do wrong?
I want to change the default numbers from english to arabic when the user switches to the arabic interface.
13 => ١٣
89 => ٨٩
What is the best way to tackle this problem?
I add in helper module
ARABIC_NUMBERS = %w(٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩)
def ta numbers
numbers = numbers.to_s if numbers.is_a? Integer
results = numbers.chars.map { |char| ARABIC_NUMBERS[char.to_i] }.join
end
Check this code : https://github.com/gdotdesign/rails-arabic-convert/blob/master/app/helpers/convert_helper.rb.
It's a helper to convert a english number to an arabic number.
I came up with this quick solution. I added the following function in the ApplicationHelper
def tn(num)
num.to_s.split(//).map{|r|t("n"+r)}.join
end
Then added translations for each number from 0 to 9 in the config/locals/ar.yml with the format below:
n1: "١"
n2: "٢"
n3: "٣"
.
.
.
Now we can call the new numeric translation function by tn(13) which will output ١٣ in arabic localization
I want to extract valid(on the basis of format) mobile numbers from a text.
e.g. I/O some text (987) 456 7890, (987)-456-7890 again some text
O/P 9874567890 9874567890
problem is, there are many valid mobile formats in all over world like.
text = "Denmark 11 11 11 11, 1111 1111 "
// + "Germany 03333 123456, +49 (3333) 123456 "
// + "Netherlands + 31 44 12345678 Russia +7(555)123-123 "
// + "spain 12-123-12-12 switzerland +41 11 222 22 22 "
// + "Uk (01222) 333333 India +91-12345-12345 "
// + "Austrailia (04) 1231 1231 USA (011) 154-123-4567 "
// + "China 1234 5678 France 01-23-45-67-89 "
// + "Poland (12) 345 67 89 Singapore 123 4567 "
// + "Thailand (01) 234-5678, (012) 34-5678 "
// + "United Kingdom 0123 456 7890, 01234 567890 "
// + "United States (987) 456 7890, (987)-456-7890+ etc."
How to cover all mobile formats?
min and max length of the mobile numbers(with or without country code)?
how to recognize that mobile number has country code or not?
You might want to check if this fits your needs: A comprehensive regex for phone number validation
By experience I know how this works in my phone OS. It looks at a long enough sequences of digits, separated by a set of allowed chars.
In principle something like:
[\+]?([0-9]|[\(\).- ]){min,max}
This regex is suboptimal since it also looks for long sequences of separator chars. You will probably need to filter those results out as well.
A very simple method with some false positives, but false positives are IMPO better than misses.
You shouldn't use the list of samples you got as a guide to actual mobile phone numbers.
For example the number sequence shown for the Netherlands is incorrect, in that it doesn't cover just mobile numbers but ALL regular phone numbers (it doesn't cover such things as 0800 and 0900 numbers for which different rules apply) and is missing an element even for that.
I can only assume the list is similarly incorrect for other countries (and of course it's far from complete in that it doesn't cover all countries, but maybe you posted only a fragment).
To parse a phone number you'd have to first remove all white space and other formatting characters from what could be a phone number, then check whether it has the correct length to be one, then try to deduce whether it includes a country code or not.
If it includes a country code but doesn't start with either 00 or + (both are used to indicate an international number) it might not be a phone number after all.
Does it include an area code? If so, is the area code one associated with mobile phones (for example in the Netherlands all mobile phone numbers have area code 06, BUT in the past this wasn't always the case so if you have an old document a 06 area code may not be a mobile number anyway.
After you've deduced that (and AFAIK mobile numbers always include an area code) you have to check if the remaining numbers make up something that could be an actual phone number without area code based on the length of the number (hint: area code + numer together have to be 10 long here, and I think everywhere).
And all that while taking into consideration that the rules may well be different for different countries or even different networks within some countries.
And of course if you find a number that looks like a valid phone number it still may not be.
It could be some other number that just looks like a phone number but isn't.
Simple search of all matching string formats in this case is not right way. The optimal way is using Regular Expressions to find all matches of phone numbers, but Blackberry java don't have built-in capabilities to process Regular Expressions.
But you can use 3-rd party library for J2ME implementing RegEx processing, smth. like this.
// Regex - Check Singapore valid mobile numbers
public static boolean isSingaporeMobileNo(String str) {
Pattern mobNO = Pattern.compile("^(((0|((\\+)?65([- ])?))|((\\((\\+)?65\\)([- ])?)))?[8-9]\\d{7})?$");
Matcher matcher = mobNO.matcher(str);
if (matcher.find()) {
return true;
} else {
return false;
}
}