numbers

what is the meaning of number 1e5?

不羁岁月 提交于 2019-11-28 09:02:14
I have seen in some codes that peaple define a variable and assign values like 1e-8 or 1e5 for example const int MAXN = 1e5 + 123; what are these numbers?! I couldnt find any thing on the web... 1e5 is a number expressed using scientific notation and it means 10 to the 5th power (the e meaning 'exponent') so 1e5 is equal to 100000 , both notations are interchangeably meaning the same. this is scientific notation for 10^5 = 100000 1e5 means 1*10^5.similarly, 1.234e5 means 1.234 * 10^5.Generally, XeY means x * 10^Y. 1e5 is 100000. 5 stand for the amount of zeros you add in behind that number.

In which case could “a != a” return “true”?

这一生的挚爱 提交于 2019-11-28 08:54:56
问题 java.lang.Math#min(double, double): public static double min(double a, double b) { if (a != a) return a; // a is NaN if (a == 0.0d && b == 0.0d && Double.doubleToLongBits(b) == negativeZeroDoubleBits) return b; return (a <= b) ? a : b; } In which case could a != a return true ? It seems that it's when a is NaN, but I can't imagine an example. Could you please provide one? 回答1: A simple example is double d = Double.NaN; // or double d = 0.0/0.0; // or double d = Double.POSITIVE_INFINITY +

Convert number to words - first, second, third and so on

不问归期 提交于 2019-11-28 08:43:15
Does anyone know how if it's possible to take an integer variable in SQL and convert it to the equivilent number of the form: First, Second, Third, Fourth etc? Thanks This seems like a simpler approach, a nice recursive algorithm CREATE FUNCTION fnIntegerToWords(@Number as BIGINT) RETURNS VARCHAR(1024) AS BEGIN DECLARE @Below20 TABLE (ID int identity(0,1), Word varchar(32)) DECLARE @Below100 TABLE (ID int identity(2,1), Word varchar(32)) INSERT @Below20 (Word) VALUES ( 'Zero'), ('One'),( 'Two' ), ( 'Three'), ( 'Four' ), ( 'Five' ), ( 'Six' ), ( 'Seven' ), ( 'Eight'), ( 'Nine'), ( 'Ten'), (

How to tell whether value is NaN without using isNaN, which has false positives? [duplicate]

♀尐吖头ヾ 提交于 2019-11-28 08:40:35
问题 This question already has answers here : How to test whether something is identically NaN? (3 answers) Closed 6 years ago . How can I check whether the input value is NaN or not without using the isNaN function? 回答1: If you can use ECMAScript 6, you have Object.is: return Object.is(obj, NaN); Otherwise, here is one option, from the source code of underscore.js: // Is the given value `NaN`? _.isNaN = function(obj) { // `NaN` is the only value for which `===` is not reflexive. return obj !==

PHP integer part padding

允我心安 提交于 2019-11-28 08:23:55
问题 I need to pad the integer part with 0, the integer part must be at least 2 characters str_pad( 2 ,2,"0",STR_PAD_LEFT);// 02 -> works str_pad( 22 ,2,"0",STR_PAD_LEFT);// 22 -> works str_pad( 222 ,2,"0",STR_PAD_LEFT);// 222-> works str_pad( 2. ,2,"0",STR_PAD_LEFT);// 2. -> fails -> 02. or 02 str_pad( 2.11 ,2,"0",STR_PAD_LEFT);// 2.11-> fails -> 02.11 Is there simple code for that? If possible the same in Java please double x=2.11; String.format("%02d%s", (int) x, String.valueOf(x-(int) x)

Turn a single number into single digits Python [duplicate]

会有一股神秘感。 提交于 2019-11-28 08:17:24
This question already has an answer here: Splitting integer in Python? 10 answers I want to make a number , for example 43365644 into single numbers [4,3,3....,4,4] and append it on a list This can be done quite easily if you: Use str to convert the number into a string so that you can iterate over it. Use a list comprehension to split the string into individual digits. Use int to convert the digits back into integers. Below is a demonstration: >>> n = 43365644 >>> [int(d) for d in str(n)] [4, 3, 3, 6, 5, 6, 4, 4] >>> Here's a way to do it without turning it into a string first (based on some

Declaring a number in Python. Possible to emphasize thousand?

一笑奈何 提交于 2019-11-28 08:15:40
问题 Is it possible to declare a number in Python as a = 35_000 a = 35,000 Neither seem to work of course. How do you emphasize things like these, for clarity in Python? Is it possible? 回答1: This is actually just now possible in Python 3.6. You can use the first format that you showed: a = 35_000 because underscores are now an accepted separator in numbers. (You could even say a = 3_5_00_0 , though why would you?) The second method you showed will actually create a tuple. It's the same as saying:

把数组排成最小的数

本小妞迷上赌 提交于 2019-11-28 08:12:04
1用全排列 再遍历去比较哪个小这个方法实在是效率太低!!! 2 用sort和字符串结合 sort中的比较函数compare要声明为静态成员函数或全局函数,不能作为普通成员函数,否则会报错。 因为:非静态成员函数是依赖于具体对象的,而std::sort这类函数是全局的,因此无法再sort中调用非静态成员函数。 静态成员函数或者全局函数是不依赖于具体对象的, 可以独立访问,无须创建任何对象实例就可以访问。 同时静态成员函数不可以调用类的非静态成员。 //牛客大神!! 这里参考代码 就是https://www.cnblogs.com/epep/p/10959627.html 有关sort的用法 不用管内部实现 只要告诉排序规则即可!!! Sort函数包含在头文件为#include<algorithm>的c++标准库中,调用标准库里的排序方法可以不必知道其内部是如何实现的,只要出现我们想要的结果即可! class Solution { public: string PrintMinNumber(vector<int> numbers) { string answer=""; sort(numbers.begin(),numbers.end(),cmp); for(int i=0;i<numbers.size();i++){ answer+=to_string(numbers[i]); }

How can I expand a string like “1..15,16” into a list of numbers?

喜夏-厌秋 提交于 2019-11-28 07:58:53
问题 I have a Perl application that takes from command line an input as: application --fields 1-6,8 I am required to display the fields as requested by the user on command line. I thought of substituting '-' with '..' so that I can store them in array e.g. $str = "1..15,16" ; @arr2 = ( $str ) ; @arr = ( 1..15,16 ) ; print "@arr\n" ; print "@arr2\n" ; The problem here is that @arr works fine ( as it should ) but in @arr2 the entire string is not expanded as array elements. I have tried using escape

Finding taxicab Numbers

半城伤御伤魂 提交于 2019-11-28 07:37:46
Find the first n taxicab numbers. Given a value n . I would like to find the first n taxicab numbers. A taxicab being a number that can be expressed as the sum of two perfect cubes in more than one way. (Note that there are two related but different sets referred to as 'taxicab numbers': the sums of 2 cubes in more than 1 way , and the smallest numbers that are the sum of 2 positive integral cubes in n ways . This question is about the former set, since the latter set has only the first six members known) For example: 1^3 + 12^3 = 1729 = 9^3 + 10^3 I would like a rough overview of the