short

Negative short primitive has wrong value on Android 24

孤者浪人 提交于 2019-12-10 23:08:14
问题 My Nexus 5X device running Android 7.0 (API level 24) has an extremely weird behavior when printing and comparing the values of short fields. public class TestActivity { public class ShortWrapper { public short s; } public void onCreate(Bundle b) { // Local short short s1 = -10; Log.d(TAG, "Local short (concatenation) = " + s1); Log.d(TAG, String.format("Local short (String.format) = %d", s1)); if(s1 == -10) Log.d(TAG, "EQUAL"); else Log.d(TAG, "!!! NOT EQUAL !!!"); // Short field

java opengl: glDrawElements() with >32767 vertices

倾然丶 夕夏残阳落幕 提交于 2019-12-10 20:29:15
问题 this must be simple, but i'm missing it. i have a complex model that has >32767 vertices. now, the indices can only be passed to opengl as type GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT. java has no concept of unsigned, so the unsigned short option maps to simply (signed) short, which is 16 bits, or +32767. when i specify the vertices, i need to pass opengl a short[], where the values in the array point to a vertex in the vertice array. however, if there are >32767 vertices, the value won't fit

confusion about short data type format specifier in C

一个人想着一个人 提交于 2019-12-10 10:06:52
问题 Consider following program: #include <stdio.h> int main() { short a=9; //printf("%hi\n",a); printf("%d",a); // LINE 6 } According to this the format specifier for short type (signed) is %hi Is the short type variable always gets promoted automatically to int before performing any operation on it? Is it undefined behavior , If I use %d format specifier to print the value of variable in this program? I compiled it using gcc -Wall -Wextra -WFormat options but still compiler isn't showing any

Converting short array to byte array in JAVA

时光总嘲笑我的痴心妄想 提交于 2019-12-10 09:51:46
问题 I am confused on how to convert short array to byte array. E.g. I have the follwoing short array short[] shrt_array = new short[]{ 0x4 , 0xd7 , 0x86, 0x8c, 0xb2, 0x14, 0xc, 0x8b, 0x2d, 0x39, 0x2d, 0x2d, 0x27, 0xcb, 0x2e, 0x79, 0x46, 0x36, 0x9d , 0x62, 0x2c }; By using this link Converting short array to byte array the two methods of conversion, I get the following two different byte arrays: expectedByteArray = new byte[] { (byte) 0x4, (byte) 0xd7, (byte) 0x86, (byte) 0x8c, (byte) 0xb2, (byte)

Ruby on Rails - generating bit.ly style uuids

≯℡__Kan透↙ 提交于 2019-12-09 06:27:51
问题 I'm trying to generate UUIDs with the same style as bit.ly urls like: http://bit.ly/aUekJP or cloudapp ones: http://cl.ly/1hVU which are even smaller how can I do it? I'm now using UUID gem for ruby but I'm not sure if it's possible to limitate the length and get something like this. I am currently using this: UUID.generate.split("-")[0] => b9386070 But I would like to have even smaller and knowing that it will be unique. Any help would be pretty much appreciated :) 回答1: You are confusing two

Unary minus on a short becomes an int?

跟風遠走 提交于 2019-12-08 17:05:53
问题 In the following: public class p { short? mID; short? dID; } short id = p.mID ?? -p.dID.Value; The compiler gives me the error: Error 21 Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?) I have to change the code to the following for it to work: short id = p.mID ?? (short)-p.dID.Value; It's as if the compiler is doing something like (int)0 - p.dID.Value, or that Int16.operator - is returning Int32s...? 回答1: I refer you to section 7.6.2 of

Workaround to get codes to work in MSVC++ 2010 due to “Type name is not allowed”

左心房为你撑大大i 提交于 2019-12-08 09:19:32
问题 I am trying to implement a finger detection, which link is given here. Am I am going through the code in MSVC2010, it gives me error as shown in Figure as shown below. Could someone tell me why the following codes gives me error? Is this related to these following questions; 1, 2, 3? Is there a possible workaround? I already included: #include <cstdint> #include <stdint.h> I also tried: unsigned short depth = (unsigned short) (v[2] * 1000.0f); // hand depth unsigned short near = (unsigned

Narrowing conversion of '65280' from 'int' to 'short int' inside { }

泪湿孤枕 提交于 2019-12-08 09:01:22
问题 I have two arrays: short GMobiles[18] = {0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x00FF, 0xFFFF}; short GMobiles2[18] = {0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05, 0xFF06, 0xFF07, 0xFF08, 0xFF09, 0xFF0A, 0xFF0B, 0xFF0C, 0xFF0D, 0xFF0E, 0xFF0F, 0xFFFF, 0xFFFF}; When I compile, I get the following message: [Warning] narrowing conversion of '65280' from 'int' to 'short int' inside { } [-Wnarrowing] for

Convert string to short in C++

耗尽温柔 提交于 2019-12-06 22:40:10
问题 So I've looked around for how to convert a string to a short and found a lot on how to convert a string to an integer. I would leave a question as a comment on those threads, but I don't have enough reputation. So, what I want to do is convert a string to a short, because the number should never go above three or below zero and shorts save memory (as far as I'm aware). To be clear, I'm not referring to ASCII codes. Another thing I want to be able to do is to check if the conversion of the

Workaround to get codes to work in MSVC++ 2010 due to “Type name is not allowed”

风格不统一 提交于 2019-12-06 16:20:24
I am trying to implement a finger detection, which link is given here . Am I am going through the code in MSVC2010, it gives me error as shown in Figure as shown below. Could someone tell me why the following codes gives me error? Is this related to these following questions; 1 , 2 , 3 ? Is there a possible workaround? I already included: #include <cstdint> #include <stdint.h> I also tried: unsigned short depth = (unsigned short) (v[2] * 1000.0f); // hand depth unsigned short near = (unsigned short) (depth - 100); // near clipping plane unsigned short far = (unsigned short) (depth + 100); //