numbers

Regular expression to allow comma and space delimited number list

落爺英雄遲暮 提交于 2019-12-04 03:28:38
问题 I want to write a regular expression using javascript or jquery to allow comma delimited list of numbers OR space delimited numbers OR comma followed by a space delimited numbers OR a combination of any of the above ex anything that is not a digit, space or comma must be rejected SHOULD PASS 111,222,333 111 222 333 111, 222, 333 111,222,333 444 555 666, 111, 222, 333, should NOT pass: 111,222,3a 3a 111 222 3a etc etc I tried the code below they seemed to work however when I typed 3a as a

Generate string of numbers python

◇◆丶佛笑我妖孽 提交于 2019-12-04 03:11:10
问题 Hello I want to create a list of strings where each string is a number. Fox example given the number 4 I would like to create a function that returns a list with elements '0','1','2','3','4'. In C/C++ this can be done by using the Ascii code of 0 and then increase them. I am new to python and I don’t know how to do it. Is there any way to do it? 回答1: You can do this with str and range like this map(str, range(number + 1)) When number = 4 , print(map(str, range(4 + 1))) # ['0', '1', '2', '3',

JavaScript regular expression to match X digits only

邮差的信 提交于 2019-12-04 03:03:36
问题 Can someone help my pea brain figure out why my simple regular expression is not working as I am expecting/wanting it to. I want to match a date format of MM/DD/YYYY with exactly 2 and 4 digits, so something like 01/16/1955. My code below does that, but it also matches 2+ and 4+ digits, so something like 011/16/1955 or 01/16/19555 (1 extra digit) pass my validation as well. //validate date of birth var dob_label = $date_of_birth.find('label').text().slice(0, -1), dob_mm = $dob_mm.val(), dob

how to create unique integer number from 3 different integers numbers(1 Oracle Long, 1 Date Field, 1 Short)

不问归期 提交于 2019-12-04 03:03:34
the thing is that, the 1st number is already ORACLE LONG, second one a Date (SQL DATE, no timestamp info extra), the last one being a Short value in the range 1000-100'000. how can I create sort of hash value that will be unique for each combination optimally? string concatenation and converting to long later: I don't want this, for example. Day Month 12 1 --> 121 1 12 --> 121 lapo When you have a few numeric values and need to have a single "unique" (that is, statistically improbable duplicate) value out of them you can usually use a formula like: h = (a*P1 + b)*P2 + c where P1 and P2 are

float number range in php. -0 is float?

扶醉桌前 提交于 2019-12-04 02:40:03
问题 when I'm converting string '-0' in float it returns float type -0 example $x = '-0'; $y = (float)$x; result => float -0 why -0 is float number ? 回答1: The IEEE 754 standard, which is how almost all computer languages implement floating point numbers, has both a +0 and a -0 value. For most operations, +0 and -0 can be used interchangeably. However, operations that error out to infinity, use +0 or -0 to go to +Infinity and -Infinity. Because -0 is a valid floating point number, it makes perfect

How do I convert a positive number to negative?

ぃ、小莉子 提交于 2019-12-04 02:36:35
How do I convert a positive Integer to a negative with Delphi? I know you could use ABS(int) to convert a negative to a positive, but I need it to convert positive to negative. from what I know there is no function for that. you can make if yourvariable > 0 then yourvariable := -yourvariable; If you want to be absolutely sure to get a negative result (or zero), use number := -abs(number) Ehhh... Too late but number := number * -1; would work too, but this change the symbol of any number, negative to positive and backwards... To ensure a negative value go with @Mef Answer EDIT: even later, but

Ideas about Generating Untraceable Invoice IDs

泪湿孤枕 提交于 2019-12-04 02:09:36
I want to print invoices for customers in my app. Each invoice has an Invoice ID . I want IDs to be: Sequential (ids entered lately come late) 32 bit integers Not easily traceable like 1 2 3 so that people can't tell how many items we sell. An idea of my own: Number of seconds since a specific date & time (e.g. 1/1/2010 00 AM). Any other ideas how to generate these numbers ? Vadim I don't like the idea of using time. You can run into all sorts of issues - time differences, several events happening in a single second and so on. If you want something sequential and not easily traceable, how

Explanation of numbers in Haskell

廉价感情. 提交于 2019-12-04 01:49:38
I would like a clear explanation of Num , Real , Integral , Integer , Int , Ratio , Rational , Double , Float . Thomas M. DuBuisson This answer mostly assumes you know the difference between types and type classes. If that difference is hazy to you then clear up your understanding there before reading on. Num Num is a typeclass that includes all numeric types. :info Num class Num a where (+) :: a -> a -> a (-) :: a -> a -> a (*) :: a -> a -> a negate :: a -> a abs :: a -> a signum :: a -> a fromInteger :: Integer -> a -- Defined in ‘GHC.Num’ instance Num Word -- Defined in ‘GHC.Num’ instance

JavaScript numbers, all the same size in memory?

爱⌒轻易说出口 提交于 2019-12-04 01:36:11
I'm reading the Number Type section of the book Professional JavaScript for Web Developers . It seems to say that all ECMAScript numbers are binary64 floating point, which is corroborated by this MDN article . But the book author also says: Because storing floating-point values uses twice as much memory as storing integer values, ECMAScript always looks for ways to convert values into integers. I expected numbers to each occupy the same amount of memory: 64 bits. And the MDN article says, "There is no specific type for integers". Anyone know what the book author meant? How can integers take up

Is there a way to round a decimal place to the nearest whole in javascript?

只谈情不闲聊 提交于 2019-12-04 01:34:55
问题 I have a number with decimal places and I am wondering if it's possible to round the decimal to the nearest whole using javascript? My number is: 4.59 I need my number to round to: 4.60 回答1: Use Number.toFixed(number of decimal places): var num = 4.59; var rounded = num.toFixed(1); 回答2: Use the toFixed() method. More detailed information at: MDN :: toFixed 回答3: var x = 4.5678; Math.round(x * 10) / 10; // 4.6 Math.round(x * 100) / 100; // 4.57 Where the number of 0 s of multiplication and