numbers

php: quickest way to generate a 5-digit number not already in MySQL db column (with a unique attribute)

你离开我真会死。 提交于 2019-12-20 03:31:18
问题 Suppose Table1 contains column orderid (not a key, although it's NOT NULL and unique). It contains 5-digit numbers. What's the best way to generate a php var $unique_var that is not in that column. What could be important, from 10% to 30% of 5-digit numbers are in the table (so generating a number and checking while (mysql_num_rows() ==0) {} is not a best way to find one, are there any better solution for performance?). Thank you. 回答1: If there is just 10-30% of numbers already taken - then

Does scientific notation affect Perl's precision?

[亡魂溺海] 提交于 2019-12-20 03:20:30
问题 I encountered a weird behaviour in Perl. The following subtraction should yield zero as result (which it does in Python): print 7.6178E-01 - 0.76178 -1.11022302462516e-16 Why does it occur and how to avoid it? P.S. Effect appears on "v5.10.0 built for x86_64-linux-gnu-thread-multi" (Ubuntu 9.04) and "v5.8.9 built for darwin-2level" (Mac OS 10.6) 回答1: It's not that scientific notation affects the precision so much as the limitations of floating point notation represented in binary. See the

VBA to remove numbers from start of string/cell

你说的曾经没有我的故事 提交于 2019-12-20 03:12:49
问题 I hope you can help. I have a piece of code that is currently removing all the text from the cells in Column G. What I need is for this code to instead of removing the text I would like it to remove the numbers, and I only want it to remove the numbers at the beginning of the string/cell the rest of the data I would like to remain the same. I have attached a picture PIC.1 for betting understanding. PIC1 The code I currently have and I hope can be amended is below and as always any and all

Why does toPrecision return a String?

非 Y 不嫁゛ 提交于 2019-12-20 03:08:24
问题 View this code: function testprecision(){ var isNotNumber = parseFloat('1.3').toPrecision(6); alert(typeof isNotNumber); //=> string } I would have expected a number. If 'isNotNumber' should be a real number, recasting is the solution: alert(typeof parseFloat(isNotNumber)) //=> number [Edit] thanks for your answers. Precision is not so precise a term I conclude. It can represent the total number of digits of a number, or the number of fractional digits . Most people in the Netherlands (where

How to insert spaces in a big number to make it more readable?

旧城冷巷雨未停 提交于 2019-12-20 01:34:16
问题 I came up with this, since other examples provided on stackoverflow were in C# string number_fmt(ulong n) { // cout << "(" << n << ")" << endl; char s[128]; sprintf(s, "%lu", n); string r(s); reverse(r.begin(), r.end()); int space_inserted = 0; size_t how_many_spaces = r.length() / 3; if(r.length() % 3 != 0) how_many_spaces += 1; for(int i = 1; i < how_many_spaces; ++i) { r.insert(3 * i + space_inserted, " "); space_inserted += 1; } reverse(r.begin(), r.end()); return r; } Do you know any

How to insert spaces in a big number to make it more readable?

梦想的初衷 提交于 2019-12-20 01:34:04
问题 I came up with this, since other examples provided on stackoverflow were in C# string number_fmt(ulong n) { // cout << "(" << n << ")" << endl; char s[128]; sprintf(s, "%lu", n); string r(s); reverse(r.begin(), r.end()); int space_inserted = 0; size_t how_many_spaces = r.length() / 3; if(r.length() % 3 != 0) how_many_spaces += 1; for(int i = 1; i < how_many_spaces; ++i) { r.insert(3 * i + space_inserted, " "); space_inserted += 1; } reverse(r.begin(), r.end()); return r; } Do you know any

How to avoid the L in Python

こ雲淡風輕ζ 提交于 2019-12-20 01:14:12
问题 >>> sum(range(49999951,50000000)) 2449998775L Is there any possible way to avoid the L at the end of number? 回答1: The L is just for you. (So you know its a long ) And it is nothing to worry about. >>> a = sum(range(49999951,50000000)) >>> a 2449998775L >>> print a 2449998775 As you can see, the printed value (actual value) does not have the L it is only the repr (representation) that displays the L Consult this post 回答2: You are looking at a Python literal representation of the number, which

“e” in a bunch of numbers [duplicate]

≯℡__Kan透↙ 提交于 2019-12-20 01:09:49
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: What number is e+000 Found 2.4397e6 in Enum tutorial Result from printing that: 2439700.0 , what does the e mean? I don't think it's primitive data type though. 回答1: It's the exponent in scientific notation - so that value is 2.4397 x 10 6 . See the JLS section 3.10.2 for precise details on floating point literals. 回答2: "e" is a exponent in scientific notation . 来源: https://stackoverflow.com/questions/13759415

Return variable with the highest value?

若如初见. 提交于 2019-12-19 21:55:34
问题 I have 3 variables: $num1, $num2, and $num3. Each represent the number of rows a table column has. I want to find which variable has the highest variable, so I can use it in a for loop (shown below) for ( $row = 1; $row <= $HIGHEST_VARIABLE; $row++) { ... } This probably was already answered, but I can't find it based on my searches 回答1: $highest = max($num1, $num2, $num3); 来源: https://stackoverflow.com/questions/5737305/return-variable-with-the-highest-value

How to limit the textarea to only hold numbers?

廉价感情. 提交于 2019-12-19 20:47:33
问题 I'm trying to make a date textbox on my blog, and the date is only numbers. I don't want anybody making a mistake typing a letter. Is there any way to limit the characters to only numerals? Thanks! 回答1: If you use jQuery, you can do it like in this jsfiddle $('input').keypress(function(e) { var a = []; var k = e.which; for (i = 48; i < 58; i++) a.push(i); if (!(a.indexOf(k)>=0)) e.preventDefault(); }); 回答2: Use HTML5 input number type instead and leverage native browser validation. Thus, no