numbers

Letter after a number, what is it called?

徘徊边缘 提交于 2019-12-18 03:53:31
问题 What is this called? double d1 = 0d; decimal d2 = 0L; float d3 = 0f; And where can I find a reference of characters I can use? If I want to cast 0 to short , which letter I need? 回答1: The best source is the C# specification (it's in section “2.4.4. Literals” in version 4). The relevant bits: The type of an integer literal is determined as follows: If the literal has no suffix, it has the first of these types in which its value can be represented: int, uint, long, ulong. If the literal is

Defining different types of numbers in C#

允我心安 提交于 2019-12-18 03:52:13
问题 You can define a number in various ways in C#, 1F // a float with the value 1 1L // a long with the value 1 1D // a double with the value 1 personally I'm looking for which would a short , however to make the question a better reference for people, what are all the other post-fix's to number literals you can apply? 回答1: Type Suffix .NET Framework Type ------------------------------------------------------------------------------------- decimal M or m System.Decimal double D or d System.Double

How to apply css to only numbers in a text inside/or any <p><p> element?

淺唱寂寞╮ 提交于 2019-12-18 03:39:06
问题 I am Using a Regional language unicode font-face in my site but the numbers are not looking good. So I want to apply new font-style or css to numbers only.. please help 回答1: This can be done using CSS's unicode-range property which exists within @font-face . The numbers 0 to 9 exist in Unicode within the range U+0030 to U+0039. So what you'll need to do is include a font alongside your existing font which specifically targets this range: @font-face { font-family: 'My Pre-Existing Font'; ... }

How to apply css to only numbers in a text inside/or any <p><p> element?

ε祈祈猫儿з 提交于 2019-12-18 03:39:05
问题 I am Using a Regional language unicode font-face in my site but the numbers are not looking good. So I want to apply new font-style or css to numbers only.. please help 回答1: This can be done using CSS's unicode-range property which exists within @font-face . The numbers 0 to 9 exist in Unicode within the range U+0030 to U+0039. So what you'll need to do is include a font alongside your existing font which specifically targets this range: @font-face { font-family: 'My Pre-Existing Font'; ... }

Formatting Large Numbers with .NET

回眸只為那壹抹淺笑 提交于 2019-12-18 03:36:08
问题 I have a requirement to format large numbers like 4,316,000 as "4.3m". How can I do this in C#? 回答1: You can use Log10 to determine the correct break. Something like this could work: double number = 4316000; int mag = (int)(Math.Floor(Math.Log10(number))/3); // Truncates to 6, divides to 2 double divisor = Math.Pow(10, mag*3); double shortNumber = number / divisor; string suffix; switch(mag) { case 0: suffix = string.Empty; break; case 1: suffix = "k"; break; case 2: suffix = "m"; break; case

getting only the first Number from String in Python

天涯浪子 提交于 2019-12-18 02:47:19
问题 I´m currently facing the problem that I have a string of which I want to extract only the first number. My first step was to extract the numbers from the string. Headline = "redirectDetail('27184','2 -New-York-Explorer-Pass')" print (re.findall('\d+', headline )) Output is ['27184', '2'] In this case it returned me two numbers but I only want to have the first one "27184". Hence, I tried with the following code: print (re.findall('/^[^\d]*(\d+)/', headline )) But It does not work: Output:[]

Python augmented assignment issue

耗尽温柔 提交于 2019-12-17 23:45:21
问题 i ran into something interesting about the python augmented assignment += it seems to be automatic data type conversion is not always done for a += b if a is a 'simpler' data type, while a = a + b seems to work always cases where the conversion is done a = 1 b = 1j a = 1 b = 0.5 case where the conversion is not done from numpy import array a = array([0, 0 ,0]) b = array([0, 0, 1j]) after a += b , a remains as integer matrix, instead of complex matrix i used to think a += b is the same as a =

Obscure / encrypt an order number as another number: symmetrical, “random” appearance?

孤者浪人 提交于 2019-12-17 21:54:24
问题 Client has an simple increasing order number (1, 2, 3...). He wants end-users to receive an 8- or 9- digit (digits only -- no characters) "random" number. Obviously, this "random" number actually has to be unique and reversible (it's really an encryption of the actualOrderNumber). My first thought was to just shuffle some bits. When I showed the client a sample sequence, he complained that subsequent obfuscOrderNumbers were increasing until they hit a "shuffle" point (point where the lower

pyramid of numbers in python

心不动则不痛 提交于 2019-12-17 21:13:01
问题 Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid, as shown in the following sample run: 1 2 1 2 3 2 1 2 3 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4 5 6 7 6 5 4 3 2 1 2 3 4 5 6 7 I have the following: num = eval(raw_input("Enter an integer from 1 to 15: ")) if num < 16: for i in range(1, num + 1): # Print leading space for j in range(num - i, 0, -1): print(" "), # Print numbers for j in range(i, 0, -1): print(j), for j in range(2, i + 1):

Checking if an int is prime more efficiently

天大地大妈咪最大 提交于 2019-12-17 20:58:38
问题 I recently was part of a small java programming competition at my school. My partner and I have just finished our first pure oop class and most of the questions were out of our league so we settled on this one (and I am paraphrasing somewhat): "given an input integer n return the next int that is prime and its reverse is also prime for example if n = 18 your program should print 31" because 31 and 13 are both prime. Your .class file would then have a test case of all the possible numbers from