int

possible lossy conversion from int to short

巧了我就是萌 提交于 2019-12-31 00:57:11
问题 I have defined array gx, array arr to be short type. but why the operation at left may end up with int type and I must cast it into short? the compiler error is possible lossy conversion from int to short. this is my code. public PixImage sobelEdges() { short gy=0; for(int x=1;x<width-1;x++){ for(int y=1;y<height-1;y++){ // if(x=){ for(int z=0;z<3;z++){ gx[x][y][z]=arr[x-1][y-1][z]-arr[x+1][y-1][z]+2*arr[x-1][y][z]-2*arr[x+1][y][z]+arr[x-1][y+1][z]-arr[x+1][y+1][z]; } // } } } return this; //

It is possible to get an IntPtr from an int[] array?

前提是你 提交于 2019-12-30 17:35:27
问题 Greetings. In C#: If I have an int[] array declared like this int[] array = new array[size]; there is an way to get the IntPtr from this array? The thing is that I'm using the EmguCV framework, and there is an constructor to create an image which takes an IntPtr to the pixel data, in order to build an image from an array (int[]). Image<Gray,Int32> result = new Image<Gray,int>(bitmap.Width,bitmap.Height,stride,"**array.toPointer??**"); By the way if someone could told me how to calculate the

Conversion failed when converting the nvarchar value 'Internet Explorer 3 original' to data type int

我们两清 提交于 2019-12-30 11:02:53
问题 In SQL Server 2008 (TSQL), I've created a stored procedure like this: CREATE PROCEDURE SP_1_10_2 AS declare @mostValuableBook nvarchar(255) SELECT @mostValuableBook = Name FROM books WHERE price = ( SELECT MAX(price) FROM books WHERE izd LIKE '%BHV%' ); return @mostValuableBook GO But, when I'm trying to execute it: declare @x nvarchar(255) EXECUTE @x = SP_1_10_2; SELECT 'The most expensive BHV book:', @x AS 'Name' GO I'm getting an error: Conversion failed when converting the nvarchar value

How to convert String variable to int in javascript?

末鹿安然 提交于 2019-12-30 10:45:13
问题 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 回答1: parseInt returns a number only if you pass it a number as first character.

Why is the sizeof(int) == sizeof(long)?

こ雲淡風輕ζ 提交于 2019-12-30 08:07:12
问题 In the program listed below, the sizeof(int) and sizeof(long) are equal on my machine (both equal 4 bytes (or 32 bits)). A long, as far as I know, is 8 bytes. Is this correct? I have a 64-bit machine #include <stdio.h> #include <limits.h> int main(void){ printf("sizeof(short) = %d\n", (int)sizeof(short)); printf("sizeof(int) = %d\n", (int)sizeof(int)); printf("sizeof(long) = %d\n", (int)sizeof(long)); printf("sizeof(float) = %d\n", (int)sizeof(float)); printf("sizeof(double) = %d\n", (int

Int to Decimal Conversion - Insert decimal point at specified location

不羁的心 提交于 2019-12-30 07:51:42
问题 I have the following int 7122960 I need to convert it to 71229.60 Any ideas on how to convert the int into a decimal and insert the decimal point in the correct location? 回答1: int i = 7122960; decimal d = (decimal)i / 100; 回答2: Simple math. double result = ((double)number) / 100.0; Although you may want to use decimal rather than double : decimal vs double! - Which one should I use and when? 回答3: Declare it as a decimal which uses the int variable and divide this by 100 int number = 700

ColdFusion 9: int and type=“numeric” nasty bug?

旧时模样 提交于 2019-12-30 07:39:16
问题 I've just experienced a behaviour that defies any logic and could potentially lead to serious issues and was wondering if it was a bug or if the behaviour was itended and what are the best practices to circumvent the issue? If it's a bug, is there a patch? Here's the two wierd behaviours that when put together are a threat to any system's data integrity. int('1 2') -> 41276 isValid('numeric', '1 2') -> true Why? Well let's see... <cffunction name="deleteSomething" access="public" returntype=

Int and String F# [closed]

本秂侑毒 提交于 2019-12-30 04:38:04
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I have a function in F#, where I take an int value and return the int as a string . let inttostring (x:int):string = ""+x I can't get

Convert String Array into Int Array Swift 2?

試著忘記壹切 提交于 2019-12-30 03:50:06
问题 [Xcode 7.1, iOS 9.1] I have an array: var array: [String] = ["11", "43", "26", "11", "45", "40"] I want to convert that (each index) into an Int so I can use it to countdown from a timer, respective of the index. How can I convert a String array into an Int Array in Swift 2? I've tried several links, none have worked and all of them have given me an error. Most of the code from the links is depreciated or hasn't been updated to swift 2, such as the toInt() method. 回答1: Use the map function

Why does adding a '0' to an int digit allow conversion to a char?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 03:10:19
问题 I've seen examples of this all over the place: int i = 2; char c = i + '0'; string s; s += char(i + '0'); However, I have not yet seen an explanation for why adding the zero allows for the conversion. 回答1: If you look at the ASCII table, asciitable, you'll see that the digits start at 48 (being '0') and go up to 57 (for '9'). So in order to get the character code for a digit, you can add that digit to the character code of '0'. 回答2: When ASCII encoding is used, the integer value of '0' is 48