signed

Little-Endian Signed Integer

强颜欢笑 提交于 2020-08-22 09:36:31
问题 I know the WAV file format uses signed integers for 16-bit samples. It also stores them in little-endian order, meaning the lowest 8 bits come first, then the next, etc. Is the special sign bit on the first byte, or is the special sign bit always on the most significant bit (highest value)? Meaning: Which one is the sign bit in the WAV format? ++---+---+---+---+---+---+---+---++---+---+---+---+---+---+---+---++ || a | b | c | d | e | f | g | h || i | j | k | l | m | n | o | p || ++---+---+---

android signed apk / net.sourceforge.jtds errors

三世轮回 提交于 2020-08-05 08:58:40
问题 I'm trying to build a signed apk (release) using proguard, but when generating the APK android studio reports several warnings related to "net.sourceforge.jtds" like this: Warning:net.sourceforge.jtds.jdbcx.JtdsDataSource: can't find superclass or interface javax.sql.XADataSource Warning:net.sourceforge.jtds.jdbcx.JtdsDataSource: can't find superclass or interface javax.naming.Referenceable ... and finally ends with an error: Error:Execution failed for task ':app

Why does len() returned a signed value?

有些话、适合烂在心里 提交于 2020-08-02 05:48:16
问题 Go's builtin len() function returns a signed int . Why wasn't a uint used instead? Is it ever possible for len() to return something negative? As far as I can tell, the answer is no: Arrays: "The number of elements is called the length and is never negative." Slices: "At any time the following relationship holds: 0 <= len(s) <= cap(s) " Maps "The number of map elements is called its length". (I couldn't find anything in the spec that explicitly restricts this to a nonnegative value, but it's

Why does len() returned a signed value?

和自甴很熟 提交于 2020-08-02 05:45:28
问题 Go's builtin len() function returns a signed int . Why wasn't a uint used instead? Is it ever possible for len() to return something negative? As far as I can tell, the answer is no: Arrays: "The number of elements is called the length and is never negative." Slices: "At any time the following relationship holds: 0 <= len(s) <= cap(s) " Maps "The number of map elements is called its length". (I couldn't find anything in the spec that explicitly restricts this to a nonnegative value, but it's

How to get a signed 32 bit integer from hex bytes without being 2's complement applied to it in java

和自甴很熟 提交于 2020-06-09 05:50:06
问题 I have 4bytes of hex values directly without two's complement being applied to signed inetger. How do I get an int value from hex bytes using java. 回答1: Doesn't this work? int value = ((0xff & b4) < 24) | ((0xff & b3) < 16) | ((0xff & b2) < 8) | (0xff & b1); 回答2: Use a Long. You can't use an int as it's always signed and 4 bytes just won't fit. Long l = Long.parseLong("FFFFFFFF", 16); 来源: https://stackoverflow.com/questions/7662819/how-to-get-a-signed-32-bit-integer-from-hex-bytes-without

Is it possible to convert a byte array to a 8-bit signed integer array in Powershell?

ぃ、小莉子 提交于 2020-03-21 05:49:07
问题 I am trying to convert a Hex string to an 8-bit signed integer array in Powershell. I am using the following function to convert a Hex string, such as A591BF86E5D7D9837EE7ACC569C4B59B, to a byte array which I then need to convert to a 8-bit signed integer array. Function GetByteArray { [cmdletbinding()] param( [parameter(Mandatory=$true)] [String] $HexString ) $Bytes = [byte[]]::new($HexString.Length / 2) For($i=0; $i -lt $HexString.Length; $i+=2){ $Bytes[$i/2] = [convert]::ToByte($HexString

signed integer division with rounding in C

て烟熏妆下的殇ゞ 提交于 2020-02-23 10:25:10
问题 I'd like to calculate x/y where x and y are both signed integers, and get a result rounded to the nearest integer. Specifically, I'd like a function rquotient(x, y) using integer-only arithmetic such that: ASSERT(rquotient(59, 4) == 15); ASSERT(rquotient(59, -4) == -15); ASSERT(rquotient(-59, 4) == -15); ASSERT(rquotient(-59, -4) == 15); ASSERT(rquotient(57, 4) == 14); ASSERT(rquotient(57, -4) == -14); ASSERT(rquotient(-57, 4) == -14); ASSERT(rquotient(-57, -4) == 14); I've looked to S.O. for

convert a java.net.InetAddress to a long

自闭症网瘾萝莉.ら 提交于 2020-02-22 05:06:12
问题 I would like to convert a java.net.InetAddress and I fight with the signed / unsigned problems. Such a pain. I read convert from short to byte and viceversa in Java and Why byte b = (byte) 0xFF is equals to integer -1? And as a result came up with: final byte [] pumpeIPAddressRaw = java.net.InetAddress.getByName (pumpeIPAddressName).getAddress (); final long pumpeIPAddress = ((pumpeIPAddressRaw [0] & 0xFF) << (3*8)) + ((pumpeIPAddressRaw [1] & 0xFF) << (2*8)) + ((pumpeIPAddressRaw [2] & 0xFF)

convert a java.net.InetAddress to a long

元气小坏坏 提交于 2020-02-22 05:05:52
问题 I would like to convert a java.net.InetAddress and I fight with the signed / unsigned problems. Such a pain. I read convert from short to byte and viceversa in Java and Why byte b = (byte) 0xFF is equals to integer -1? And as a result came up with: final byte [] pumpeIPAddressRaw = java.net.InetAddress.getByName (pumpeIPAddressName).getAddress (); final long pumpeIPAddress = ((pumpeIPAddressRaw [0] & 0xFF) << (3*8)) + ((pumpeIPAddressRaw [1] & 0xFF) << (2*8)) + ((pumpeIPAddressRaw [2] & 0xFF)

How to print a signed integer as hexadecimal number in two's complement with python?

假装没事ソ 提交于 2020-01-21 10:56:29
问题 I have a negative integer (4 bytes) of which I would like to have the hexadecimal form of its two's complement representation. >>> i = int("-312367") >>> "{0}".format(i) '-312367' >>> "{0:x}".format(i) '-4c42f' But I would like to see "FF..." 回答1: Here's a way (for 16 bit numbers): >>> x=-123 >>> hex(((abs(x) ^ 0xffff) + 1) & 0xffff) '0xff85' (Might not be the most elegant way, though) 回答2: >>> x = -123 >>> bits = 16 >>> hex((1 << bits) + x) '0xff85' >>> bits = 32 >>> hex((1 << bits) + x)