numeric

How does SQL Server store decimal type values internally?

空扰寡人 提交于 2019-12-04 10:08:34
In SQL Server you can use FLOAT or REAL to store floating point values the storage format of which is cleared defined by the IEEE 754 standard. For fixed point values we can use DECIMAL type (which has a synonym NUMERIC ). However I'm not pretty sure how SQL Server store DECIMAL values internally. For example, if I define a table and insert a row like this: IF OBJECT_ID('dbo.test_number_types') IS NOT NULL DROP TABLE dbo.test_number_types; CREATE TABLE dbo.test_number_types ( id INT IDENTITY(1, 1), c1 NUMERIC(5, 4) ) GO INSERT INTO dbo.test_number_types(c1)VALUES(5.7456); When I use DBCC PAGE

Java / Scala math library with elliptic integrals and bessel functions?

南笙酒味 提交于 2019-12-04 09:53:35
I am looking for a math library for scientific computing to use in Java / Scala. Especially I need complete elliptic integrals und modified Bessel functions. I would be nice if it is open source, but I guess I will have to take whatever is out there. A scipy (python lib for scientific computing) replacment would be great :-) As far as I'm aware, the most widely used Java math libraries are: The Apache Commons Math library , and The Colt project (developed by CERN ) You'll have to investigate their respective APIs though to determine if they provide exactly the functionality you require. I know

How to convert factor format to numeric format in R without changing the values? [duplicate]

冷暖自知 提交于 2019-12-04 09:03:44
This question already has answers here : How can i convert a factor column that contains decimal numbers to numeric? (4 answers) Closed 6 years ago . Below is dataframe df1 of which I want to convert column "V2" from factor format to numeric without changing the current values (0 ; 0 ; 8,5 ; 3). df1= V1 V2 V3 X2 X3 4470 2010-03-28 0 A 21.53675 0 4471 2010-03-29 0 A 19.21611 0 4472 2010-03-30 8,5 A 21.54541 0 4473 2010-03-31 3 A NA NA Since column "V2" is in factor format I first convert it to character format: df1[,2]=as.character(df1[,2]) Then I try to convert "V2" to numeric format: df1[,2]

Is it possible to set a number to NaN or infinity?

大城市里の小女人 提交于 2019-12-04 07:24:58
问题 Is it possible to set an element of an array to NaN in Python? Additionally, is it possible to set a variable to +/- infinity? If so, is there any function to check whether a number is infinity or not? 回答1: Cast from string using float() : >>> float('NaN') nan >>> float('Inf') inf >>> -float('Inf') -inf >>> float('Inf') == float('Inf') True >>> float('Inf') == 1 False 回答2: Yes, you can use numpy for that. import numpy as np a = arange(3,dtype=float) a[0] = np.nan a[1] = np.inf a[2] = -np.inf

Strange addition of numeric strings in PHP

社会主义新天地 提交于 2019-12-04 05:19:30
问题 I'm adding together two numerical strings $a and $b and then comparing the result against another numerical string $c. All three numbers are stored as strings, and being converted to floats by PHP at the comparison step. For some reason, the test $a+$b == $c does not evaluate as true, even though it should. You can recreate the problem with this script: <?php $a = "-111.11"; $b = "-22.22"; $c = "-133.33"; echo '$a is '.$a."\n"; echo '$b is '.$b."\n"; echo '$c is '.$c."\n"; echo '$a + $b is '.

Scala Generics and Numeric Implicits

爱⌒轻易说出口 提交于 2019-12-04 05:04:44
I need to pass two functions as parameters to a scala function. That function should then evaluate them and get a number from them where it will then operate on. This number can be either a Int, Double or any other numeric type. I would like the function to work, whatever the types it is working with. The example bellow explains the issue. import Numeric.Implicits._ class Arithmetic[T : Numeric](val A: Connector[T], val B: Connector[T]) { val sum = new Connector({ A.value + B.value }) } class Constant[T](var x: T) { val value = new Connector({ x }) } class Connector[T](f: => T) { def value: T

Android EditText default numeric keyboard and allow text [duplicate]

◇◆丶佛笑我妖孽 提交于 2019-12-04 04:58:59
This question already has answers here : Closed 6 years ago . Possible Duplicate: EditText with number keypad by default, but allowing alphabetic characters Wondering if it is possible to default to a numeric keyboard on focus for an edittext field but also allow users to input characters? None of the input types seem to support this. Thanks! I just tried to add a number text field in Android and it ran in the emulator fine. It defaults to bring up the number pad first, but you can switch to characters just as easy. So try to use a number text field. <EditText android:id="@+id/editText1"

Get categories from numeric vector

≯℡__Kan透↙ 提交于 2019-12-04 04:46:49
问题 I have this numeric vector: vec <- 1:7 How can I transform it into 3 categories using these logical rules: if(vec >= 1 && vec < 4) then "category1" else if(vec >=4 && vec < 6) then "category2" else if(vec >= 6 && vec < 8) then "category3" The expected result would be: result <- c("category1","category1","category1", "category2","category2", "category3","category3") UPDATE: What if category names are not sequential (i.e. cat1,cat2,cat3)? e.g. if(vec >= 1 && vec < 4) then "night" else if(vec >

Encoding a numeric string into a shortened alphanumeric string, and back again

倾然丶 夕夏残阳落幕 提交于 2019-12-04 04:03:38
Quick question. I'm trying to find or write an encoder in Python to shorten a string of numbers by using upper and lower case letters. The numeric strings look something like this: 20120425161608678259146181504021022591461815040210220120425161608667 The length is always the same. My initial thought was to write some simple encoder to utilize upper and lower case letters and numbers to shorten this string into something that looks more like this: a26Dkd38JK That was completely arbitrary, just trying to be as clear as possible. I'm certain that there is a really slick way to do this, probably

Overriding fromInteger in Haskell

为君一笑 提交于 2019-12-04 03:13:13
So I like Haskell, but am dissatisfied with the Num class. So I want to make my own typeclass hierarchic for algebraic types. The problem is, even if I import Prelude hiding Num and everything associated with it, still the only way to make the literal 1 have type t is to make t instance Num. I would love to make my own fromInteger class and leave Num out of the picture entirely, like this import Prelude hiding (everything having to do with Num) import qualified Prelude (everything having to do with Num) class (Eq fi) => FromInteger fi where fromInteger :: Integral -> fi foo :: (FromInteger fi)