numbers

Increment decimal, floating point numbers

别等时光非礼了梦想. 提交于 2019-12-11 15:12:56
问题 Can anyone explain the best logic / method for incrementing floating, decimal numbers ? For example, if we assume starting decimal number is 2.0, so the next items should automatically get number accordingly say, 2.01, 2.02, 2.03, ....., 2.09, 2.10, 2.11.. etc. But what is the starting number is 2.1, so what would be the next sequence : Is it ? 2.11, 2.12, 2.13, 2.14, ..... 2.19, 2.20 etc...? I is logically correct? I am confused. Please help. 回答1: It depends entirely on what the application

Find string in text file and set variable with windows batch

浪子不回头ぞ 提交于 2019-12-11 15:04:19
问题 I have a file named hdd_list.txt . Index: 0 Device Name: \Device\Harddisk0\Partition0 Drive: entire disk Label: Type: Harddisk Size: 55.899GB Index: 1 Device Name: \Device\Harddisk0\Partition1 Drive: C:\ Label: Type: Harddisk Size: 55.897GB Index: 2 Device Name: \Device\Harddisk1\Partition0 Drive: entire disk Label: Type: Harddisk Size: 465.761GB Index: 3 Device Name: \Device\Harddisk1\Partition1 Drive: E:\ Label: Backup Type: Harddisk Size: 465.758GB I need to retrieve Index number

Datatable sort numbers dont work

流过昼夜 提交于 2019-12-11 14:58:43
问题 I have a datatable on my website and try to sort numbers with 1,999,999,999 but it doesn't work. I tried to fix the problem with a lot of tips on Google but it does not helped me. Thats the javascript code for my table $('.d3uitems').dataTable({ "bJQueryUI": true, "sPaginationType": "full_numbers", "sDom": '<""l>t<"F"p>', 'aaSorting': [[ 0, 'desc' ]] }).columnFilter({ aoColumns: [ null, { type: "text"}, null, null, { type: "text"}, null ] }); Here is the Datatable where i try to sort the

Remove useless zero digits from decimals in PHP

懵懂的女人 提交于 2019-12-11 14:51:53
问题 I'm trying to find a fast way to remove zero decimals from number values like this: echo cleanNumber('125.00'); // 125 echo cleanNumber('966.70'); // 966.7 echo cleanNumber(844.011); // 844.011 Does exists some optimized way to do that? 回答1: $num + 0 does the trick. echo 125.00 + 0; // 125 echo '125.00' + 0; // 125 echo 966.70 + 0; // 966.7 Internally, this is equivalent to casting to float with (float)$num or floatval($num) but I find it simpler. 回答2: you could just use the floatval function

Get individual digits from an Int without using strings?

99封情书 提交于 2019-12-11 14:18:46
问题 I know you can convert the Int to a string and get the digit at position x using the indexer as if it was a char array, but this conversion becomes a bit of an overhead when you're dealing with multiple large numbers. Is there a way to retrieve a digit at position x without converting the number to a string? EDIT: Thank you all, I will benchmark the proposed methods and check if it is any better than converting to a string. Thread will stay unanswered for 24h in case anyone has better ideas.

Round just decimal in Javascript

穿精又带淫゛_ 提交于 2019-12-11 13:36:32
问题 I have a value like that: 20.93 I'd like to round it to 20.90 How can I do that in Javascript ? Thanks! 回答1: Multiply the number by 10, round it and then divide the number by 10: var result = Math.round(20.93 * 10) / 10 回答2: I think this should work: number .toFixed(1); 回答3: var num= 20.93 num = Math.floor(num * 10) / 10; // 20.9 num = Math.ceil(num * 10) / 10; //21 回答4: I take it that you want the trailing zero. None of the answers give you that. It has to be a String to have the trailing

Project Euler #3 Java

∥☆過路亽.° 提交于 2019-12-11 13:06:13
问题 public class Problem3 { public static void main (String args[]) { System.out.print(primeMod(60085147514L)); } public static double primeMod(long d) { long max = 0; int count = 0; for (long i = 2; i < d; i++) { if (d % i == 0) { boolean isPrime = primeCounter(i); if(isPrime == true) { max = i; System.out.println(max); } } else { max = max; } } return max; } public static boolean primeCounter(long x) { int count = 0; for (int s = 1; s <= x; s++) { if (x % s == 0) { count++; } } if (count == 2)

problems with trivial number conversions in Haskell

旧街凉风 提交于 2019-12-11 11:52:51
问题 I am attempting to write a trivial function to drop the last digit of a number and return the rest of the number. dropLastDigit :: (Integral b) => b -> b dropLastDigit x = (quot x 10) * (floor $ logBase 10 x) however, when I try to load this into ghci, I get: Could not deduce (Floating b) arising from a use of ‘logBase’ from the context (Integral b) bound by the type signature for dropLastDigit :: Integral b => b -> b at haskelljokes.hs:6:18-39 Possible fix: add (Floating b) to the context of

javascript returns 9 for 0011 [duplicate]

北战南征 提交于 2019-12-11 11:36:16
问题 This question already has answers here : How do I work around JavaScript's parseInt octal behavior? (10 answers) Closed 4 years ago . I have a function where I passes the value dynamically <a href="javascript:void(0);" onclick="searchError(0011)">0011</a> In javascript am just passing this value and it returns me 9 JS function searchError(s){ alert(s); } Need help to understand why ? I fixed it by quoting the value like <a href="javascript:void(0);" onclick="searchError('0011')">0011</a> JS

How to see if a string has more numbers than other symbols in java

回眸只為那壹抹淺笑 提交于 2019-12-11 11:33:59
问题 So for an assignment I have to make a programm that asks for a input of a string and then detects palindromes. thing is, also numbers can be put in. When more than half of the input of the string is a number it needs to regard the string as a numeric string and disregard the other symbols. So what i thought is to put the input string into an array then look for the numbers (ASCII# between 48 and 57) and count those. Afterwards compare the number of Numbers vs number of Letters and see which