numeric

Why is numeric_limits<int>::max() > numeric_limits<int>::infinity()?

我与影子孤独终老i 提交于 2019-12-12 09:29:00
问题 I was reading Setting an int to Infinity in C++. I understand that when one needs true infinity, one is supposed to use numeric_limits<float>::infinity() ; I guess the rationale behind it is that usually integral types have no values designated for representing special states like NaN , Inf , etc. like IEEE 754 floats do (again C++ doesn't mandate neither - int & float used are left to the implementation); but still it's misleading that max > infinity for a given type. I'm trying to

Is there a datatype “Decimal” in R?

試著忘記壹切 提交于 2019-12-12 08:19:36
问题 I read data stored in the format DECIMAL from a MySQL-Table. I want to do calculations on those numbers within R. I used to cast them to a numeri represaentation using as.numeric() , but the documentation says: numeric is identical to double (and real). But is there also a datatype Decimal in R? (Datatype without rounding errors,...) Here a simple example for the problem with rounding errors: numbersStrings = c("0.1", "0.9") numbersNumeric = as.numeric(numbersStrings) numbersMirror = c

Submatrix view from indices in Eigen

假装没事ソ 提交于 2019-12-12 01:55:31
问题 Is it possible in Eigen to do the equivalent of the following operation in Matlab? A=rand(10,10); indices = [2,5,6,8,9]; B=A(indices,indices) I want to have a submatrix as a view on the original matrix with given, non consecutive indices. The best option would be to have a shared memory view of the original matrix, is this possible? I've figured out a method that works but is not very fast, since it involves non vectorized for loops: MatrixXi slice(const MatrixXi &A, const std::set<int>

How to convert text to numeric format in SAS

人走茶凉 提交于 2019-12-11 22:35:24
问题 I have a big dataset from a data warehouse where one of the varibels have been read in as a string. The variable only contains numbers and I havn't got the raw data so I can't read in the data myself. Example: Variabel 4659721685425645 1234564578978896 7894567894567894 The format is $20. and the informat is $19. I want to convert it into numeric so I can join the dataset with another dataset, on the same variable, but where this variable is numeric. I have already tried: data x_numeric; set x

Lucene hibernate search NumericRangeQuery<Float> not working on field defined with @NumericField

北城余情 提交于 2019-12-11 20:08:24
问题 I use hibernate search 4.1.0 with good results except for this problem. I´m trying to perform a range search in a column defined: @Field(name = "startTime", store = Store.YES) @NumericField public Float startTime; I have stored an item with startTime = 0.0f; then I try to perform a range query: NumericRangeQuery<Float> rangeQuery = NumericRangeQuery.newFloatRange( "startDate", -100000.0f, +100000.0f, true, true); FullTextQuery fullTextQuery = fullTextEntityManager .createFullTextQuery

Default numeric format in Excel

人走茶凉 提交于 2019-12-11 19:02:57
问题 I have a web app that exports reports to Excel. It does this by sending the HTML of the report table to the clipboard, and then pasting it into Excel. Quick and dirty. And it comes through fairly well. Numbers are formatted as numbers, dates as dates, and so on. But the reports have negative numbers formatted to use parentheses rather than a minus sign, and when this is pasted into Excel, it changes to a minus sign. You can see this in action simply by typing (200) into Notepad, and then

why as.numeric function in R doesn't work properly?

假如想象 提交于 2019-12-11 18:33:10
问题 I have these two characters and the "as.numeric" function doesn't work same for them. Can anyone help me why this is happening? options(digits=22) a="27" as.numeric(a) [1] 27.00000000000000000000 a="193381411288395777" as.numeric(a) [1] 193381411288395776.0000 It can be seen that in the second case the last digit is not "7" and it is "6". Basically the "as.numeric" function decreases 1 unit from the number in the second case. Any help is appreciated. 回答1: You need to learn about the limits of

bash sorting numbers with decimals [duplicate]

随声附和 提交于 2019-12-11 16:59:20
问题 This question already has answers here : Sorting numbers with multiple decimals in bash (3 answers) Unix sort of version numbers (7 answers) Sort version strings on bash (2 answers) Closed 2 years ago . I have a file like so: 1.1 3.2 1.2 1.10 I would like to sort the file so that it looks like so: 1.1 1.2 1.10 3.2 In other words, 1.10 is bigger than 1.2 I tried: sort -nk 1,1 file But I keep getting this, which is not what I want 1.1 1.10 1.2 3.2 Thanks 回答1: With GNU sort: sort -t "." -n -k1,1

Split numeric part from alphanumeric string using C#

旧巷老猫 提交于 2019-12-11 07:51:11
问题 I have alphanumeric string list. For example: 1A 2B 7K 10A I want to get only the numeric part and then compare them, if it is less than 10 I need not to add it in another list. What I want to know the regex to split the numeric part from the string. Any help. What I have done till now is: if (x == y) // also handles null return 0; if (x == null) return -1; if (y == null) return +1; int ix = 0; int iy = 0; while (ix < x.Length && iy < y.Length) { if (Char.IsDigit(x[ix]) && Char.IsDigit(y[iy])

In R, why does is.numeric(NaN) print “TRUE”?

早过忘川 提交于 2019-12-11 07:23:59
问题 NaN` means "Not a Number". However I found out that the result of is.numeric(NaN) is [1] "TRUE" Anybody know why? I think the result should be FALSE . 回答1: "Not a Number" does not really mean it is not a number. It is a special coding of a floating-point number. See ANSI/IEEE 754 floating-point standard , or simply the Wikipedia page for NaN. This is a universal standard for all computing languages and R's handling is no exception. In R, typeof(NaN) gives "double", and mode(NaN) gives