numbers

how to display arabic numbers inside iPhone apps without localizing each digit

只愿长相守 提交于 2019-11-29 14:18:54
问题 I want to know how to display arabic numbers inside iPhone apps without localizing each digit. like for example, I have an integer in the code whose value = 123 I want to display it as ١٢٣ without having to localize each digit on its own and force the app to use arabic as the localization language regardless of the user's chosen language because I have many numbers all over the application that change dynamically, so I need a generic smart solution 回答1: NSDecimalNumber *someNumber =

prolog convert numbers into roman numerals

杀马特。学长 韩版系。学妹 提交于 2019-11-29 14:00:19
i have this code that converts integers into roman numerals i need to add a function that compares an integer with a roman numeral input and show if it's try or false, for example: roman(v,5). true toroman(0). toroman(N) :- N < 4, put("I"), M is N - 1, toroman(M). toroman(N) :- N = 4, put("I"), put("V"). toroman(N) :- N = 5, put("V"). toroman(N) :- N < 9, put("V"), M is N - 5, toroman(M). toroman(N) :- N = 9, put("I"), put("X"). toroman(N) :- N < 40, put("X"), M is N - 10, toroman(M). toroman(N) :- N < 50, put("X"), put("L"), M is N - 40, toroman(M). toroman(N) :- N < 90, put("L"), M is N - 50

How can I view Arabic/Persian numbers in a HTML page with strict doctype?

不羁岁月 提交于 2019-11-29 13:33:27
I have an HTML page that is right-to-left. When I don't use any doctype, my numbers are in Arabic/Persian, but when I use strict mode they turn to English. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Final//EN"> Before adding doctype: After adding doctype: also I added these meta tags to my page: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Language" content="fa" /> So how can I view Arabic numbers in a page with strict doctype (in IE because Firefox doesn't show Arabic numbers anyway)? here is a little javascript code that converts a 1234

How to print all digits of a large number in python?

∥☆過路亽.° 提交于 2019-11-29 13:20:27
So, I have a very large number that I'm working out in python, but when I try to print it I get something like this: 3.101541146879488e+80 How do I print all the digits of my lovely number? both int and long work for this >>> a 3.101541146879488e+80 >>> int(a) 310154114687948792274813492416458874069290879741385354066259033875756607541870592L >>> long(a) 310154114687948792274813492416458874069290879741385354066259033875756607541870592L >>> print (int(a)) 310154114687948792274813492416458874069290879741385354066259033875756607541870592 >>> print (long(a))

RowFilter.NumberFilter: can't handle “mixed” concrete number types

大兔子大兔子 提交于 2019-11-29 13:08:20
Happens if at least one of the values (values == value in RowFilter, value in entry) is a decimal. Here's a failing test: @Test public void testRowFilterNumberMixCore() { TestEntry entry = new TestEntry(1.2f); RowFilter filter = RowFilter.numberFilter(ComparisonType.AFTER, 1, 0); assertTrue(entry + "must be included " + filter, filter.include(entry)); } The output is: junit.framework.AssertionFailedError: [entry: 1.2] must be included [RowFilter: ComparisonType = AFTER, comparableValue: 1, comparableClass: class java.lang.Integer] The reason is that NumberFilter falls back to comparing the

Rounding values up or down in C#

醉酒当歌 提交于 2019-11-29 13:07:05
I've created a game which gives a score at the end of the game, but the problem is that this score is sometimes a number with a lot of digits after the decimal point (like 87.124563563566). How would I go about rounding up or down the value so that I could have something like 87.12? Thanks! Try using Math.Round . Its various overloads allow you to specify how many digits you want and also which way you want it to round the number. Use Math.Ceiling(87.124563563566) or Math.Floor(87.124563563566) for always rounding up or rounding down. I believe this goes to the nearest whole number. To always

How do I find the difference between two values without knowing which is larger?

馋奶兔 提交于 2019-11-29 13:07:05
I was wondering if there was a function built into Python that can determine the distance between two rational numbers but without me telling it which number is larger. e.g. >>>distance(6,3) 3 >>>distance(3,6) 3 Obviously I could write a simple definition to calculate which is larger and then just do a simple subtraction: def distance(x, y): if x >= y: result = x - y else: result = y - x return result but I'd rather not have to call a custom function like this. From my limited experience I've often found Python has a built in function or a module that does exactly what you want and quicker

Convert scientific notation to decimals

拈花ヽ惹草 提交于 2019-11-29 12:36:35
问题 I have numbers in a file (so, as strings) in scientific notation, like: 8.99284722486562e-02 but I want to convert them to: 0.08992847 Is there any built-in function or any other way to do it? 回答1: I'm pretty sure you can do this with: float("8.99284722486562e-02") # and now with 'rounding' "{:.8f}".format(float("8.99284722486562e-02")) 回答2: The scientific notation can be converted to a floating point number with float. In [1]: float("8.99284722486562e-02") Out [1]: 0.0899284722486562 The

How to write own isnumber() function?

拈花ヽ惹草 提交于 2019-11-29 12:34:40
I'm new to C and I'm thinking how to write this function myself. I take a parameter from command line, so it is stored in argv array and I want to decide whether it is or isn't number. What is the easiest way to do this? Thank you #include <stdio.h> int isNumber(int *param) { if (*param > 0 && *param < 128) return 1; return 0; } int main(int argc, char *argv[]) { if (argc == 2) isNumber(argv[1]); else printf("Not enought parameters."); return 0; } Read about strtol(3) . You could use it as bool isnumber(const char*s) { char* e = NULL; (void) strtol(s, &e, 0); return e != NULL && *e == (char)0;

how to avoid number repeation by using random class in c#?

陌路散爱 提交于 2019-11-29 12:30:14
hi i am using Random class for getting random numbers but my requirement is once it generate one no that should not be repeate again pls help me. Keep a list of the generated numbers and check this list before returning the next random. Since you have not specified a language, I'll use C# List<int> generated = new List<int>; public int Next() { int r; do { r = Random.Next() } while generated.Contains(r); generated.Add(r); return r; } The following C# code shows how to obtain 7 random cards with no duplicates. It is the most efficient method to use when your random number range is between 1 and