numbers

Auto generated sequence number staring from 001 ( ONLY FOR 3 DIGITS) - PHP / MYSQL

故事扮演 提交于 2019-12-06 06:02:26
I need Auto generated sequence number staring from 001 ONLY FOR 3 DIGITS in PHP / MYSQL ex: 001 next will be 002 and next will be 003 ... 009 .. 010 ..119..120..etc but number generated should be in sequence wise not like 001 then 120 or 008 etc , i need in sequence number. actually i have product tracking system . where i need mixer of my main product id + auto sequence number ( only 3 digit can change if wanted ) hence my final product id becomes : 111-001 , 111-002 , 111-003 , 111-004 ....etc Note: this auto sequence number will be insert in my mysql database ( after ADD button follows by

android edittext inputfilter should accept space,character & number

試著忘記壹切 提交于 2019-12-06 05:24:59
street = (EditText) findViewById(R.id.street); InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end,Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { if (!Character.isLetterOrDigit(source.charAt(i)) || !Character.isSpaceChar(source.charAt(i))) { return ""; } } return null; } }; street.setFilters(new InputFilter[] { filter }); my edittext is able to filter character & number on the virtual keyboard but not taking the space character.. plz help instead of '||' i replaced with '&&' and got the answer.... !Character

Finding the closest number downward to a different number from an array

左心房为你撑大大i 提交于 2019-12-06 05:11:25
问题 Example: I have an array like this: [0,22,56,74,89] and I want to find the closest number downward to a different number. Let's say that the number is 72 , and in this case, the closest number down in the array is 56 , so we return that. If the number is 100 , then it's bigger than the biggest number in the array, so we return the biggest number. If the number is 22 , then it's an exact match, just return that. The given number can never go under 0, and the array is always sorted. I did see

All possibilities that are less than X using only Y numbers?

孤街浪徒 提交于 2019-12-06 04:46:24
问题 Say I have these numbers: [2, 25, 37, 54, 54, 76, 88, 91, 99] (these are random) And I need to find all combinations of those numbers that are less than 100. Not all numbers have to be used in these combinations. Examples: 2, 2+25+37, 54+25 How can I achieve this in JavaScript? Thanks 回答1: So if you have an array of numbers: var arr = [2, 25, 37, 54, 54, 76, 88, 91, 99] First filter the array to just that which is less than 100 var filtered = arr.filter(function(val){ return val < 100; });

Generate a random number sequence to get and average

混江龙づ霸主 提交于 2019-12-06 03:59:38
问题 I am looking to generate a number sequence where each number is between 70 and 100 there will be x numbers in the sequence and it will give and average of y. What would this algorithm look like? 回答1: I think it is impossible for them to be uniformly distributed between 70 and 100 and have a given average at the same time. What you can do is generate random numbers that have a given average and then scale them to fit into [70, 100] (but they will not be uniformly distributed there). generate

Faster way to find out if a number starts with 2?

ぃ、小莉子 提交于 2019-12-06 03:47:33
问题 In Java - what is the faster way to find if the given integer number is starting with the digit 2 without having to convert the number into a string? String.valueOf(number).charAt(0) == '2' 回答1: If you wanted to avoid converting it to a string, you could just keep dividing by 10 to find the most significant digit: int getMostSignificantDigit(int x) { // Need to handle Integer.MIN_VALUE "specially" as the absolute value can't // represented. We can hard-code the fact that it starts with 2 :) x

How to restrict the EditText input content

三世轮回 提交于 2019-12-06 03:47:15
I am trying to create a simple calculator which provides the EditText for the users to input the numbers. The allowing input content should be [1,2,3,4,5,6,7,8,9,0,.] I know that it is possible to limit the input content by using following code android:digits="1234567890." android:inputType="phone" But how can I prevent the users from adding more than one dot ( . ) into the EditText Box? You can use this digits attribute android:digits="0123456789" You can use InputFilter limit characters in an EditText as: EditText mEdit = (EditText)findViewById(R.id.mEdit); InputFilter[] filters = {new

Remove E sign from big float number , C#?

孤人 提交于 2019-12-06 03:37:15
问题 If you used big float numbers , you found in C# big float number is showed like this : 2000000 * 2000000 = 4E+12 How can I show 4E+12 as 4,000,000,000,000 not 4E+12 ? 回答1: You want number.ToString("N0"); "N0" is Number with no decimal places. The alternative - "F0" is Fixed-point with no decimal places but prints without the comma separators: double number = 4e12; Console.WriteLine(number.ToString("F0")); Console.WriteLine(number.ToString("N0")); prints: 4000000000000 4,000,000,000,000 Source

Rounding to the Nearest Ending Digits

瘦欲@ 提交于 2019-12-06 03:32:45
I have the following function that rounds a number to the nearest number ending with the digits of $nearest , and I was wondering if there is a more elegant way of doing the same. /** * Rounds the number to the nearest digit(s). * * @param int $number * @param int $nearest * @return int */ function roundNearest($number, $nearest, $type = null) { $result = abs(intval($number)); $nearest = abs(intval($nearest)); if ($result <= $nearest) { $result = $nearest; } else { $ceil = $nearest - substr($result, strlen($result) - strlen($nearest)); $floor = $nearest - substr($result, strlen($result) -

Ruby undefined method `+' for nil:NilClass (NoMethodError)

旧巷老猫 提交于 2019-12-06 03:29:35
New to Ruby. Receiving error: undefined method `+' for nil:NilClass (NoMethodError) I do not understand why I am receiving an error for such a simple task of incrementing a value. However, perhaps the error is caused by something else. What is the cause? class LinkedList class Node attr_accessor :data, :nextNode def initialize(data = nil, nextNode = nil) @data = data @nextNode = nextNode end end #member variables @head = nil @size = 0 def initialize @head = Node.new() end def add(val) curr = @head while curr.nextNode != nil curr = curr.nextNode end curr.nextNode = Node.new(val) @size += 1 #<<<