unsigned

Signed and unsigned integers?

妖精的绣舞 提交于 2021-01-28 07:58:56
问题 Could someone please explain the two to me because I have to give an explanation of them both in my assignment. I know what a normal integer is of course and have used the following to describe it: "An integer is a whole number which can be positive, negative and zero but it cannot have decimal points." But I'm just not sure about signed and unsigned. Thanks 回答1: In most languages when you declare an integer, you are declaring a signed integer. If you want to declare an unsigned integer you

The difference between signed and unsigned, what means a negative byte?

二次信任 提交于 2021-01-28 07:02:41
问题 I need to solve the problem below, but I don't understand the concepts needed for solution. Let's consider the following string of doublewords: B234* A68C *h, * 52B4 *78C8h, * 1AB3 *C470h, F9DC* 98B6 *h. It is required to: 1) print on the screen the words ' ranks that have the minimum value from each doubleword (considering them unsigned ) The answer is '2112' (the bold words have the minimum value) 2) print on the screen the sum of the bytes that have the maximum value from these words

How to handle the unsigned types (especially u4) of a Java class file in a Java program?

本小妞迷上赌 提交于 2021-01-28 05:54:39
问题 From the Java Virtual Machine specification: A class file consists of a stream of 8-bit bytes. All 16-bit, 32-bit, and 64-bit quantities are constructed by reading in two, four, and eight consecutive 8-bit bytes, respectively. Multibyte data items are always stored in big-endian order, where the high bytes come first. In the Java platform, this format is supported by interfaces java.io.DataInput and java.io.DataOutput and classes such as java.io.DataInputStream and java.io.DataOutputStream.

Why does C++ prints unsigned char value as negative?

懵懂的女人 提交于 2021-01-27 11:50:44
问题 I'm trying to understand the implicit conversion rules in C++ and I understood that when there are one operation between two primary types the "lower type" is promoted to the "higher type", so let say for: int a = 5; float b = 0.5; std::cout << a + b << "\n"; should print 5.5 because 'a' gets promoted to float type. I also understood that unsigned types are "higher types" than the signed counter parts so: int c = 5; unsigned int d = 10; std::cout << c - d << "\n"; prints 4294967291 because 'c

Why does C++ prints unsigned char value as negative?

坚强是说给别人听的谎言 提交于 2021-01-27 11:45:12
问题 I'm trying to understand the implicit conversion rules in C++ and I understood that when there are one operation between two primary types the "lower type" is promoted to the "higher type", so let say for: int a = 5; float b = 0.5; std::cout << a + b << "\n"; should print 5.5 because 'a' gets promoted to float type. I also understood that unsigned types are "higher types" than the signed counter parts so: int c = 5; unsigned int d = 10; std::cout << c - d << "\n"; prints 4294967291 because 'c

Unsigned long in Java

蓝咒 提交于 2021-01-26 03:06:20
问题 Currently, I am using signed values, -2^63 to 2^63-1. Now I need the same range (2 * 2^64), but with positive values only. I found the java documentations mentioning unsigned long, which suits this use. I tried to declare 2^64 to a Long wrapper object, but it still loses the data, in other words, it only captures till the Long.MAX_VALUE , so I am clearly missing something. Is BigInteger the signed long that Java supports? Is there a definition or pointer as to how to declare and use it? 回答1:

Unsigned long in Java

一笑奈何 提交于 2021-01-26 03:06:11
问题 Currently, I am using signed values, -2^63 to 2^63-1. Now I need the same range (2 * 2^64), but with positive values only. I found the java documentations mentioning unsigned long, which suits this use. I tried to declare 2^64 to a Long wrapper object, but it still loses the data, in other words, it only captures till the Long.MAX_VALUE , so I am clearly missing something. Is BigInteger the signed long that Java supports? Is there a definition or pointer as to how to declare and use it? 回答1:

Should I use “mul” or “imul” when multiplying a signed number to an unsigned number?

爷,独闯天下 提交于 2021-01-01 04:19:30
问题 I have found out that both mul and imul can be used to multiply a signed number to an unsigned number. For example: global _start section .data byteVariable DB -5 section .text _start: mov al, 2 imul BYTE [byteVariable] You can replace imul with mul , and the result would still be the same ( -10 ). Are mul and imul exactly the same when multiplying a signed number to an unsigned number, or is there a difference between them? 回答1: The upper half is different, as mentioned in the comments. If

Why is std::streamsize defined as signed rather than unsigned?

依然范特西╮ 提交于 2020-11-30 07:56:19
问题 According to http://en.cppreference.com/w/cpp/io/streamsize The type std::streamsize is a signed integral type used to represent the number of characters transferred in an I/O operation or the size of an I/O buffer. As far as I can imagine, a stream's size can never be negative, so, my question is: Why is std::streamsize defined as signed rather than unsigned ? What's the rationale behind? 回答1: The draft C++ standard has the following footnote 296 in section 27.5.2 Types which says: