numbers

Display flaw with HTML input type number on iPhone iOS/Safari

烈酒焚心 提交于 2019-11-30 15:33:49
I want to use HTML input type="number" on a mobile application, in order to indicate to the smarter mobile phones (Android, iPhone and some others), that the numeric keyboard is more interesting for the user than the normal one. This works nicely. So, I have this piece of HTML here: <h3>type="number"</h3> <input type="number" class="input-number"/> <h3>type="text"</h3> <input type="text" class="input-text"/> The important CSS elements applied here are: input { height: 2em; padding: 0.2em 0.5em; width: 100%; /* avoid iPhone rounded corners */ border: 1px solid #afb7c1; border-collapse: collapse

How can I sort a list of strings by numbers in them?

懵懂的女人 提交于 2019-11-30 14:52:25
问题 An easy one no doubt for you... I have a list of filenames which are like so; fw_d.log.1.gz through fw_d.log.300.gz When i use this below code block, it almost sorts it the way i want, but not quite. #!/usr/bin/perl -w my $basedir = "/var/log"; my @verdir = qw(fw_d); my $fulldir; my $configs; my $combidir; foreach $combidir (@verdir) { $fulldir = "$basedir/$combidir"; opendir (DIR, $fulldir); my @files = grep { $_ ne '.' && $_ ne '..' && $_ ne 'CVS' readdir DIR; closedir (DIR); @files1 = sort

Comparing anagrams using prime numbers

本秂侑毒 提交于 2019-11-30 14:14:31
There is the problem of trying to see if two unique strings are anagrams of each other. The first solution that I had considered would be to sort both strings and see if they were equal to each other. I have been considering another solution and I would like to discuss if the same would be feasible. The idea would be to assign a numerical value to each character and sum it up such that a unique set of characters would produce a unique value. As we are testing for anagrams, we do not mind if the checksum of "asdf" and "adsf" are the same -- in fact, we require it to be that way. However the

Converting number abbreviations (5.2k, 1.7m, etc) into valid integers with PHP

左心房为你撑大大i 提交于 2019-11-30 14:07:56
I have a database with a column containing a variety of numbers written in "shorthand", for example: 5k for 5,000 86.6k for 86,600 4.1m for 4,100,000 1.2b for 1,200,000,000 I'd like to do some calculations with these numbers for a PHP frontend, but I need to convert them into valid integers in order to do so. How could I do this with PHP? Something like: switch (strtolower(substr($input, -1))) { case 'k': $input*=1000; break; // similarly for m, M, b, B. } Assuming your data is well-formatted. If not more check would be needed like: if (!preg_match('/^\d+(?:\.\d+)?[mbk]$/i',$input)) { //

how to generate integer random number in fortran 90 in the range [0,5]?

风格不统一 提交于 2019-11-30 14:01:46
问题 I am kind of new in the fortran proramming. Can anyone please help me out with the solution. i am having a problem of generating integer random number in the range [0,5] in fortran random number using random_seed and rand 回答1: To support the answer by Alexander Vogt, I'll generalize. The intrinsic random_number(u) returns a real number u (or an array of such) from the uniform distribution over the interval [0,1). [That is, it includes 0 but not 1.] To have a discrete uniform distribution on

Sublime Text 2 increment numbers

我怕爱的太早我们不能终老 提交于 2019-11-30 13:52:56
I have a JSON file that looks like this: "Algeriet" : [ { "name" : "Nyårsdagen", "date" : "2013-01-01", "ID" : "1" }, { "name" : "Mawlid En Nabaoui Echarif", "date" : "2013-01-24", "ID" : "2" }, { "name" : "Första maj", "date" : "2013-05-01", "ID" : "3" }, ... ] Now I would like to begin incrementing the IDs from 0 instead of 1. How can I do this with Sublime Text 2? I have installed the Text Pastry plugin but I'm not sure how to select the IDs in the text so that I can replace these values. Peter Warbo Solved it by doing these steps: Do a find and replace for regex "ID" : "\d+" and replacing

Parse String into Number

偶尔善良 提交于 2019-11-30 13:45:54
问题 I have a list which will store Number objects. The list will be populated by parsing a list of strings, where each string may represent any subclass of Number. How do I parse a string to a generic number, rather than something specific like an integer or float? 回答1: Number cannot be instantiated because it is an abstract class. I would recommend passing in Numbers, but if you are set on Strings you can parse them using any of the subclasses, Number num = Integer.parseInt(myString); or Number

Don't allow typing alphabetic characters in a <input type=number />

给你一囗甜甜゛ 提交于 2019-11-30 13:45:37
问题 I need to have a textbox, where, whenever typed inside should ONLY allow numbers [0-9]. I've used type="number" which definitely holds the client side validation but also allows to type other alphabets. I can do it by tracking each keydown and matching with regex but I was wondering if there is any way I can restrict to type using only html tags and NOT defining any functions in JavaScript to compare in each keydown? Code not sufficient to do so is: <input type="number" id="txt_number"

Making use of sandy bridge's hardware true random number generator?

筅森魡賤 提交于 2019-11-30 13:07:06
I was wondering if there is a way to make use of the new hardware based true number generator found in intel's sandy bridge CPU? I read that intel's MKL (Math Kernel Library) exposes this functionality, but this requires the MKL suite and an intel complier, ending up pretty expensive. Is there another way to employ the hardware random number generator in my C++ code? For example a nice, header only library? Intel has posted a manual, library, and code examples for the rdrand instruction at http://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software

How to speed up series generation?

只谈情不闲聊 提交于 2019-11-30 12:50:32
问题 The problem requires to generate the n-th element of a sequence that is similar to Fibonacci sequence. However, it's a bit tricky because n is very large (1 <= n <= 10^9). The answer then modulo 1000000007. The sequence is defined as follows: Using generating function, I obtain the following formula: If I use the sequence approach then the answer can be modulo, but it run extremely slow. In fact, I got time limit exceed many times. I also tried to use a table to pre-generate some initial