numeric

PostgreSQL: IN A SINGLE SQL SYNTAX order by numeric value computed from a text column

浪子不回头ぞ 提交于 2019-12-02 01:12:29
A column has a string values like "1/200", "3.5" or "6". How can I convert this String to numeric value in single SQL query? My actual SQL is more complicated, here is a simple example: SELECT number_value_in_string FROM table number_value_in_string's format will be one of: ## #.## #/### I need to sort by the numeric value of this column. But of course postgres doesn't agree with me that 1/200 is a proper number. Seeing your name I cannot but post a simplification of your answer: SELECT id, number_value_in_string FROM table ORDER BY CASE WHEN substr(number_value_in_string,1,2) = '1/' THEN 1

Numpy Array Slicing

空扰寡人 提交于 2019-12-01 20:09:24
I have a 1D numpy array, and some offset/length values. I would like to extract from this array all entries which fall within offset, offset+length, which are then used to build up a new 'reduced' array from the original one, that only consists of those values picked by the offset/length pairs. For a single offset/length pair this is trivial with standard array slicing [offset:offset+length] . But how can I do this efficiently (i.e. without any loops) for many offset/length values? Thanks, Mark There is the naive method; just doing the slices: >>> import numpy as np >>> a = np.arange(100) >>>

javascript (jquery) numeric input: keyCode for '3' and '#' are the same

帅比萌擦擦* 提交于 2019-12-01 15:51:10
I need to set up an <input type="text" /> so that it will accept only numeric chars, backspace, delete, enter, tabs and arrows. There's a lot of exemple around there, i started with something similar to this: function isNumericKeyCode (keyCode){ return ( (keyCode >= 48 && keyCode <= 57) //standard keyboard ||(keyCode >= 96 && keyCode <= 105)) //Numpad } $('#myTextBox').keydown(function(e){ var handled = true; var keyCode = e.keyCode; switch(keyCode){ //Enter and arrows case 13: case 37: case 38: case 39: case 40: doSomethingSpecialsWithThesesKeys(); break; default: handled = false; break; } if

Am I using a wrong numerical method?

房东的猫 提交于 2019-12-01 13:04:20
问题 This is the code: f = dsolve('D3y+12*Dy+y = 0 ,y(2) = 1 ,Dy(2) = 1, D2y(2) = -1'); feval(symengine, 'numeric::solve',strcat(char(f),'=1'),'t=-4..16','AllRealRoots') If I remove 'AllRealRoots' option it works fast and finds a solution, but when I enable the option Matlab does not finish for an hour. Am I using a wrong numerical method? 回答1: First, straight from the documentation for numeric::solve: If eqs is a non-polynomial/non-rational equation or a set or list containing such an equation,

Checking to see if text box input is numeric

大憨熊 提交于 2019-12-01 12:46:35
I've done some research on this and still cannot get my program to work. I simply need to check the text box to see if the user input is a numeric value, or not (with the exception of a "." and or "/") My code so far, Private Sub Num1_KeyPress(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Num1.KeyPress Dim UserEntry As Boolean If UserEntry = IsNumeric(False) Then MessageBox.Show("That's not numeric!") End If End Sub I think you better be using TextBox.KeyUp event, it passes the KeyEventArgs . Try this : Private Sub Num1_KeyUp(sender As System.Object, e As System.Windows

How to restart sliding animation in Easy Slider 1.7

空扰寡人 提交于 2019-12-01 10:41:00
问题 I've got a question about the jQuery Easy Slider 1.7 http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider with numeric navigation. When i use the slider with auto, continous set to true, the automatic sliding animation stops when I click on a number. Is there a way to make the animation after certain time delay? I tried adding timeout = setTimeout(function(){ animate("next",false); },options.pause); to if(clicked) clearTimeout(timeout); making it: if(clicked)

Checking to see if text box input is numeric

耗尽温柔 提交于 2019-12-01 10:09:53
问题 I've done some research on this and still cannot get my program to work. I simply need to check the text box to see if the user input is a numeric value, or not (with the exception of a "." and or "/") My code so far, Private Sub Num1_KeyPress(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Num1.KeyPress Dim UserEntry As Boolean If UserEntry = IsNumeric(False) Then MessageBox.Show("That's not numeric!") End If End Sub 回答1: I think you better be using TextBox.KeyUp event,

How to convert String variable to int in javascript?

空扰寡人 提交于 2019-12-01 08:22:18
What is the correct way to convert value of String variable to int/numeric variable? Why is bcInt still string and why does isNaN return true ? bc=localStorage.getItem('bc'); var bcInt=parseInt(bc,10); var bcInt2=1; console.log("bc------------>" +bc +" isNaN:" +isNaN(bc)); //isNaN returns true console.log("bcInt------------>" +bcInt +" isNaN:" +isNaN(bcInt)); //isNaN returns true bcInt2// isNaN returns false parseInt returns a number only if you pass it a number as first character. Examples: parseInt( 'a', 10 ); // NaN parseInt( 'a10', 10 ); // NaN parseInt( '10a', 10 ); // 10 parseInt( '', 10

as.numeric is rounding off values

心不动则不痛 提交于 2019-12-01 07:16:31
I am trying to convert a character column from a data frame to the numerics. However, what I am getting as a result are rounded up values. Whatever I have tried by researching other questions of the same nature on SO, hasn't worked for me. I have checked the class of the column vector I am trying to convert, and it is a character, not a factor. Here is my code snippet: some_data <- read.csv("file.csv", nrows = 100, colClasses = c("factor", "factor", "character", "character")) y <- Vectorize(function(x) gsub("[^\\.\\d]", "", x, perl = TRUE)) some_data$colC <- y(data1$colC) data1$colD <- y(data1

R floating point number precision being lost on coversion from character

廉价感情. 提交于 2019-12-01 06:16:01
I have a large floating point number as a character like so x<-"5374761693.91823"; On doing as.numeric(x); I get the following output 5374761694 I would like to preserve the floating point nature of the number while casting. use digits argument in print to see the actual number: > print(as.numeric(x), digits=15) [1] 5374761693.91823 options is another alternative: > options(digits=16) > as.numeric(x) [1] 5374761693.91823 > # assignments > options(digits=16) > y <- as.numeric(x) > y [1] 5374761693.91823 z <- print(as.numeric(x), digits=15) z 来源: https://stackoverflow.com/questions/17878703/r