Questions tagged [short]
A short integer is an integer number which may take less storage, while having a smaller range, than a standard integer on the same machine.
608
questions
0
votes
0
answers
42
views
Is it okay to declare a variable as Byte then convert to Int in Kotlin?
So i want to use Byte and Short to decrease memory usage, but some methods asks explicitly for Int.
private val numberOne : Byte = 50
someMethodAskingInt(numberOne.toInt())
If i convert a variable to ...
1
vote
2
answers
35
views
Short and byte data types don't work in loop [duplicate]
I can't add two short numbers when they are in a loop, but when they outside loop they adds well. Byte type behaves the same. But with integers everything works well. Why does this happening?
Java, ...
1
vote
1
answer
36
views
Want another way shortcode about sqlcode
please, i want find another way
example data
date
tomato
phone
book
pen
2022-05-15
2
2
3
1
2022-05-15
3
3
3
2
i see this result
date
tomato
phone
book
pen
2022-05-15
5
5
6
3
i use this
insert ...
0
votes
1
answer
41
views
I don't understand why I get the compiler error "Lossy conversion from int to short"
For this code:
public class Solution{
public static void main(String[] args){
short x = 10;
x = x * 5;
System.out.print(x);
...
0
votes
0
answers
13
views
how to add code for Take Profit and Stop Loss to the following code?
please your help to add code TP with percentage (%) i can change it from setting of script to work with how many (X) use in future...I use this script https://www.tradingview.com/script/eYhCV71m/ ......
0
votes
1
answer
69
views
QT String to short int - Hex Value
I want to convert QString to short int. For eg,
Input:
QString str = "0x0001";
Output:
short int num = 0x0001;
I have tried toShort() method of QString but it converts "0x0024" to ...
-1
votes
1
answer
79
views
QByteArray to short Int array in QT C++
I am receiving a QByteArray from UDP Socket. The QByteArray is of 52 elements each containing values from 0 to 9 - A to F. Now, I want to convert this QByteArray into a short int array of 13 elements ...
0
votes
1
answer
35
views
Issues converting Hex to Short getting the wrong value
I have a function that converts 2 char values into an unsigned short:
unsigned short ToShort(char v1, char v2) {
unsigned short s = ((v1 << 8) | v2);
return s;
}
It works most of the ...
0
votes
2
answers
49
views
Is there a way to write a method that outputs the number of digits before the decimal point of a float parameter as a short?
I need to output the total number of digits before the decimal point of a float number and output the results as a short.
This is what I have so far:
public static void main(String[] args) {
...
0
votes
2
answers
69
views
C++ casting char into short
Pardon me for this newbie question. I recently found that a strange thing when casting char into short. Basically, if the char is overflowed, when casting into short the binary number is prepended ...
0
votes
0
answers
147
views
How to show recently added items first in recyclerview (Firebase)- 2021 [duplicate]
how to disbanding recyclerview firebase DB. please help
I need to develop a small news app. I add news every time the 1st news only shows in 1st position. I want to view the last added news in 1st ...
0
votes
3
answers
312
views
Printf in unsigned short int and unsigned int using %d
Why in second printf when using %d I am not getting -1?
#include<stdio.h>
int main(){
unsigned int u=-1;
unsigned short int y=-1;
printf("%d %u\n",u,u);
printf("%d ...
1
vote
2
answers
95
views
converted an integer to short in C, get 4-byte when printed short
I converted an integer value to short, but when I printed the hexadecimal result of short, it was shown in 4-bytes, I can't find the reason.
#include <stdio.h>
void main()
{
int j = 53191;
...
1
vote
1
answer
184
views
Printf with short integer compiler warning
#include <stdio.h>
int main(void)
{
short i = 1;
printf("%hd\n", i);
printf("%hd\n", i * i);
return 0;
}
Compiling this gives the warning warning: format specifies ...
0
votes
2
answers
35
views
I'm getting the value of b as 2130 can anyone explain me the process and tell me why?
public class Main {
public static void main(String[] args) {
byte x = 126;
short y = 32734;
int z = 32789;
long a = 50000L + 10L * (x + y + z);
System.out.println(a);
short b = ...
1
vote
0
answers
89
views
What is GCC's un-optimized asm doing to add two short ints in assembly?
In this code example
typedef struct { short int a1; short int a2;} st1;
typedef struct { int sum; int diff;} st2;
st2 test (st1 s1) {
st2 store;
store.sum = s1.a1 + s1.a2;
store.diff = s1....
-3
votes
2
answers
74
views
Change part of the bits in a short in C++? [closed]
I have packed data of rgba values in an 16 bit short, so for each channel goes 4bit, how can I change specific channel only, lets say I want to change red channel to it's value devided by two. I know ...
0
votes
2
answers
284
views
Pointer Arithmetic long and short in 32bit or 64bit System
I am just studying for an exam and the following question is asked, what output does the following program generate in 32 bit or 64 bit?
#include <stdio.h>
int main(int argc, char **argv)
{
...
0
votes
1
answer
65
views
Separate bits from short[] in order of most to least significant C#
I want to separate the bits of a short[] contained in a byte[] so the most significant bit of each short are arranged in one contiguous block(array? line?) followed by the next bit from each short and ...
0
votes
0
answers
6
views
why readInt () gives me an incorrect value when readInt> 266?
I have an invisible file. I am trying to read it by the following code (part of code), but when the value of readInt ()> 256, the program displays an incorrect value (example 16777422). could ...
1
vote
1
answer
129
views
Short unsigned int in C++ [duplicate]
So in my exam in the class I was supposed to declare X as a short unsigned. I declared it short unsigned int X. Is this way still OK and correct? Thank you
0
votes
1
answer
146
views
Convert a binary number from type short into a decimal number in C
I need to read from a file a binary number that is represented by type short in C language.
the number represents the size of an array so after I read it I want to use the number as a decimal value.
I ...
0
votes
1
answer
73
views
Assigning a short to int * fails
I understand that I can reassign a variable to a bigger type if it fits, ad its ok to do it. For example:
short s = 2;
int i = s;
long l = i;
long long ll = l;
When I try to do it with pointers it ...
0
votes
1
answer
448
views
Can I get the robocopy log file to just display one line of the summary and date? instead of having multiple columns? thank you
So far I have this code to just show the summary of the robocopy. Can I just make this really short and 1 line? Like a line that shows the total size copied, the date, and if it was successful or ...
1
vote
0
answers
100
views
std::ofstream doesn't work with short enums in C++Builder 10.3
If I set "Short enums" to true (Project -> Options -> C++ Compiler), I receive an Access Violation in return from a function where std::ofstream is used.
Example code:
#include <...
0
votes
0
answers
56
views
I would like to change ugly address link on my subpages of galleria (Gallery)
grimlord.eu/galeria and its subpages has ugly adress.
http://www.grimlord.eu/index_pl.php?src=gallery&sub=koncertowe
http://www.grimlord.eu/index_pl.php?src=gallery&sub=studio
http://www....
1
vote
1
answer
205
views
Deprecated Short(String) how to update?
I'm handling this problem:
produto.setQuantidade(new Short("7"));
Short appears deprecated with a mark. How can I update this for above Java 9 versions? (Now, I have Java 11)
0
votes
0
answers
27
views
How to find sum of a field by finding chronological order in another field in R? [duplicate]
I have an excel file with below columns
I want to add duration field for each member (A and B) date wise.
In here I want data like:
UserName Date Duration
A 22-07-2019 2
B 22-...
2
votes
2
answers
109
views
Scala bit Short
In my console, when I try to check (0xFFFF.toShort).toBinaryString, it returns
(0xFFFF.toShort).toBinaryString
res1: String = 11111111111111111111111111111111
Shouldn't it return 1111111111111111, as ...
0
votes
1
answer
81
views
Encoding bytes in ushort and back again
I am trying to store two bytes in a ushort. So the first 8 bit is the first value and the 8 last bits, the last. I almost have it working, but I this error in line 20, where I bit shift:
Severity ...
-2
votes
2
answers
182
views
How to convert double array to short array in java? [duplicate]
I have array of double in java and I need to convert into array of short. Any idea?
0
votes
1
answer
110
views
Cannot convert from Function<Short, Object> to Function<Short, Short>
So, this university exercise asks to write a method that takes as an argument a Function<Short, Short> and result type a Function<Short, Short>. It should return the outcome of the ...
0
votes
2
answers
684
views
How to convert int to short int in C?
Let's say I've got a char array[5] = {'1','2','3','4','\0'};.
If I want the integer, I can simply use the atoi()-function:
int num = atoi(array);
How could I retrieve the value as short/short int?
Of ...
-3
votes
1
answer
44
views
Byte to Integer why Number changes [duplicate]
Why the number changes from byte to integer or from short to byte to integer?
Here the code:
public class TypeCasting {
public static void main ( String [] args ) {
short c = 292;
...
0
votes
1
answer
38
views
short doesn't overflow visual c++ 2017
Input of 32760 and 9 print out 32769, not -32767.
I don't know what else to do, it's a simple program, but it doesn't work as I want.
#include <iostream>
using namespace std;
int main()
{
...
0
votes
1
answer
107
views
Python convert a value to 16 bit 2's complement
Is it possible to convert a value(int) in python to signed 2's complement 16 bit format? I am looking for a functionality similar to short used in Java.
value = (short) v;
0
votes
0
answers
40
views
java.lang.ShortCache.cache contained wrong value
One of my applications decided today to return 1, when
Short.valueOf("0")
was called.
I discovered, that
ShortCache.cache[128]
was set to 1 instead of 0, the other cached values were ...
0
votes
1
answer
144
views
CompareTo() method of short in C#
I want to use CompareTo() method in C#. When I use it with long and int data types the comare result is always -1, 0, 1.
What about data type short? When I compare two values (less than, greater than) ...
0
votes
3
answers
74
views
Java Method returns wrong value after left and right arithmetic bit-shifting
I have a method that looks like this:
private short getAddress(short ir) { //performs bit shifting to isolate and find address
short addr = ir;
addr = (short) (addr << 11); //...
-1
votes
1
answer
42
views
Suppose you have a decimal -12 what is the signed 4 bit representaion of it [closed]
Suppose you have decimal -12 what is the signed 4 bit representaion of it.
basically -12 = 1 0100 how can i convert this to 4 bit
0
votes
0
answers
28
views
if value is equal to either a or b. shorthand? [duplicate]
Yea some javascript shorthand.
if that value is equal to the value of a or b, maybe something like this?
if(val==a||b)
-2
votes
2
answers
260
views
how can i use any command for cut an command output
Command outputs i want to cut :
{"logging_page_id":"profilePage_28345663","show_suggested_profiles":false,"show_follow_dialog":false,"graphql":{"...
1
vote
3
answers
104
views
how to delete the short lists from a long nested list even the items are not continuous using Python?
For example:
t=[[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6], [2, 3, 4, 5, 6], [3, 5], [4, 5, 6],[4,5,6],[6,7], [6], [1]]
I want to delete the short lists if the items are included in a long one, even the ...
0
votes
2
answers
52
views
Outputting bit values for unsigned short (C)
I have a function that takes an unsigned short and displays the bit values for it. Currently it displays all but the leading 0's, and I would like to display all 16 bit places instead.
void ...
0
votes
1
answer
20
views
Umuly short link creating service problem
when i do a post https://umuly.com/api/url with body : { "RedirectUrl": "www.youtube.com"}
i get this message:
{
"status": 400,
"statusText": "...
1
vote
1
answer
42
views
shorten length string ignore Non-Space Characters like arabic diacritic Character without cutting words
lets say i have this string that contain Non-Space Characters:
thisHُ is a long string I cant display
as you can see this "Hُ " contain Non-Space Characters now i want to short the string ...
0
votes
1
answer
279
views
SHRT_MIN in C as hex
I wanted to display the highest and lowest "short" values as hexadecimal numbers (using a Windows environment, mingw64 compiler):
printf("largest %x and smallest %x",SHRT_MAX,...
-1
votes
2
answers
979
views
How to initialize List<Short> in one line?
How to initialize a list of short elements in one line?
Something like this:
List<Short> numbers = new ArrayList<Short>(List.of(1, 2, 3, 4, 5));
But I am getting:
"Cannot resolve ...
1
vote
1
answer
884
views
How do I convert a float to a 16 bit signed integer fraction in C?
I'm using a macro from a library supplied by NXP for their Arm M4F to convert from a float typed variable to a library data type called frac16_t and it doesn't work when the float value is less than -...
0
votes
1
answer
120
views
why a loop condition can run indefinitely when compares int to short
There is a loop used in my code, for which coverity is throwing the error -
Infinite loop, loop_bound_type_mismatch: Loop bound someArray.length
has type int, which is wider in size or has a bigger ...