numbers

Weird output, when number starts with 0

旧街凉风 提交于 2019-12-02 07:48:19
1. script: $num = "00445790"; echo $num; returns: 00445790 2. script $num = 00445790; echo $num; returns: 2351 Can somebody explain why I get 2351 on the second script? John Conde Integers that start with zero are consider octal. Because octal integers only use numbers from 0 to 8 everything from the 9 on are ignored. So 00445790 becomes 004457 which is 2351 in decimal. 来源: https://stackoverflow.com/questions/30629817/weird-output-when-number-starts-with-0

Oracle 12c - is index on a 'number' column performing faster than index on 'varchar' column?

陌路散爱 提交于 2019-12-02 07:28:04
Let's say I have a table in Oracle 12c with columns: create table t1 ( a number (5,0), b varchar (5,0) d ... e ... ); Then I insert 100,000,000 records in both columns which have the same values - e.g. 20151 and '20152' ... (for a first record) 20152 and '20152' ... (for a second record) 20153 and '20153' ... (for a third record) ... Then I add index 1 on column 'a' and index 2 on column 'b'. Question is - would the query perform equally fast when executing against column 'a' as on column 'b' (e.g. join query with other table based on a column 'a' or based on a column 'b' or WHERE clause on

Matlab: Numerical array index into a string array (without loops)

假装没事ソ 提交于 2019-12-02 07:23:46
问题 I'm doing a set of problems from the MATLAB's introductory course at MIT OCW. You can see it here, it's problem number 9, part g.iii. I have one matrix with the final grades of a course, all of them range from 1 to 5. And I have another array with only letters from 'F' to 'A' (in a 'decreasing' order). I know how to change elements in a matrix, I suppose I could do something like this for each number: totalGrades(find(totalGrades==1)) = 'F'; totalGrades(find(totalGrades==2)) = 'E';

Extract maximum number from a string

♀尐吖头ヾ 提交于 2019-12-02 07:21:58
I am trying to extract all numbers from a string with a function in Excel. In the second time, I would like to extract the maximum value contains in the string. My string look likes : ATCG=12.5,TTA=2.5,TGC=60.28 Desired output: 60.28 In a first time, I am trying to extract all numbers with my function but it stops only on the first figure. Function MyCode(ByVal txt As String) As String With CreateObject("VBScript.RegExp") .Pattern = "\d.+" If .test(txt) Then MyCode = .Execute(txt)(0) End With End Function Your decimal separator may be different from the US decimal separator. Public Function

Squaring number in c++, Kaprekar numbers [duplicate]

早过忘川 提交于 2019-12-02 07:20:30
问题 This question already has answers here : Multiplication of two integers in C++ (3 answers) Closed 3 years ago . Found this issue in C++ while detecting Kaprekar numbers in a range. For number 77778 - unsigned long long sq = pow(n, 2); returns 6,049,417,284 while unsigned long long sq = n * n; returns 1,754,449,988 Any ideas why? Is this some sort of overflow which pow avoids but normal n*n does not. 回答1: Assuming your n to be typical int or unsigned int , the reason for this is because this

Decimal point in calculations as . or ,

大城市里の小女人 提交于 2019-12-02 07:11:21
问题 If I use decimal pad for input of numbers the decimal changes depending of country and region format. May be as a point "." or as a comma "," And I do not have control over at which device the app is used. If the region format uses a comma the calculation gets wrong. Putting in 5,6 is the the same as putting in only 5 some times and as 56 same times. And that is even if I programmatically allow both . and , as input in a TextField. How do I come around this without using the numbers an

剑指:扑克牌的顺子

折月煮酒 提交于 2019-12-02 06:33:16
题目描述 从扑克牌中随机抽 5 张牌,判断是不是一个顺子,即这5张牌是不是连续的。 2~10 为数字本身, A 为 1 , J 为 11 , Q 为 12 , K 为 13 ,大小王可以看做任意数字。 为了方便,大小王均以 0 来表示,并且假设这副牌中大小王均有两张。 样例1 输入:[8,9,10,11,12] 输出:true 样例2 输入:[0,8,9,11,12] 输出:true 解法一 对数组排序; 计算出 0 的个数 zeroCount ; 从第一个不是 0 的数字开始遍历,与后一个数字比较,如果相等,直接返回 false ;否则累计 gap ; 判断 zeroCount 是否大于等于 gap 。 import java.util.Arrays; class Solution { /** * 判断是否是连续的数字 * * @param numbers 数组 * @return 是否是顺子 */ public boolean isContinuous(int [] numbers) { if (numbers == null || numbers.length == 0) { return false; } int zeroCount = 0; Arrays.sort(numbers); for (int e : numbers) { if (e > 0) { break;

What's algorithm used to solve Linear Diophantine equation: ax + by = c

一曲冷凌霜 提交于 2019-12-02 06:29:15
I'm looking for integers solution here. I know it has infinitely many solution derived from the first pair solution and gcd(a,b)|c. However, how could we find the first pair of solution? Is there any algorithm to solve this problem? Thanks, Chan Note that there isn't always a solution. In fact, there's only a solution if c is a multiple of gcd(a, b) . That said, you can use the extended euclidean algorithm for this. Here's a C++ function that implements it, assuming c = gcd(a, b) . I prefer to use the recursive algorithm: function extended_gcd(a, b) if a mod b = 0 return {0, 1} else {x, y} :=

JSP 自我学习笔记2

ぐ巨炮叔叔 提交于 2019-12-02 06:23:33
JSP 自我学习笔记2 一 .学习目标 主要学习jsp中的jsp:include,jsp:forward,jsp:param 二 .讲解内容 jsp:include动作 jsp:include动作是在主页面被请求时,将次级页面的输出包含进来。尽管被包含的页面的输出中不能含有JSP,但这些页面可以是其他资源所产生的 结果。服务器按照正常的方式对指向被包含资源的URL进行解释,因而这个URL可以是Servlet或JSP页面。服务器以通常的方式运行被包含的页面, 将产生的输出放到主页面中,这种方式与RequestDispatcher类的include方法一致。它的优点是在被包含的页面发生更改时,无须对主页 面做出修改。它的缺点是所包含的是次级页面的输出,而非次级页面的实际代码,所以在被包含的页面中不能使用任何有可能在整体上影响主页面的JSP构造。 语法: <jsp:include page="sample.jsp" flush="true"> <jsp:param name="name" value="value"/> </jsp:include> 其中参数设置可以没有,如果没有参数设置,则必须采用 <jsp:include page="sample.jsp" flush="true"/> jsp:forward动作

Check if variable is a number and positive integer in PHP?

久未见 提交于 2019-12-02 06:14:53
For example, say: <?php // Grab the ID from URL, e.g. example.com/?p=123 $post_id = $_GET['p']; ?> How do I check if variable $post_id is a number, and a positive integer at that (i.e. 0-9, not a floating point number, fraction, or a negative number)? EDIT: Can't use is_int 'cause $_GET returns a string. Think I need to use intval() or ctype_digit() , with the latter seeming more appropriate. For example: if( ctype_digit( $post_id ) ) { ... } To check if a string input is a positive integer, i always use the function ctype_digit . This is much easier to understand and faster than a regular