signed

Parser for signed overpunch values?

隐身守侯 提交于 2019-11-30 21:34:33
I am working with some old data imports and came across a bunch of data from an external source that reports financial numbers with a signed overpunch . I've seen alot, but this is before my time. Before I go about creating a function to parse these strangers, I wanted to check to see if there was a standard way to handle these. I guess my question is, does the .Net framework provide a standard facility for converting signed overpunch strings? If not .NET, are there any third party tools I can use so I don't reinvent the wheel? Over-punched numeric ( Zoned-Decimal in Cobol) comes from the old

How to convert signed 32-bit int to unsigned 32-bit int?

自作多情 提交于 2019-11-30 20:07:26
This is what I have, currently. Is there any nicer way to do this? import struct def int32_to_uint32(i): return struct.unpack_from("I", struct.pack("i", i))[0] Not sure if it's "nicer" or not... import ctypes def int32_to_uint32(i): return ctypes.c_uint32(i).value using numpy for example: import numpy result = numpy.uint32( numpy.int32(myval) ) or even on arrays, arr = numpy.array(range(10)) result = numpy.uint32( numpy.int32(arr) ) 来源: https://stackoverflow.com/questions/16452232/how-to-convert-signed-32-bit-int-to-unsigned-32-bit-int

Why is (18446744073709551615 == -1) true?

假装没事ソ 提交于 2019-11-30 17:48:25
When I was working on string::npos I noticed something and I couldn't find any explanation for it on the web. (string::npos == ULONG_MAX) and (string::npos == -1) are true. So I tried this: (18446744073709551615 == -1) which is also true. How can it be possible? Is it because of binary conversation? Evan Carroll 18,446,744,073,709,551,615 This number mentioned, 18,446,744,073,709,551,615 , is actually 2^64 − 1 . The important thing here is that 2^64-1 is essentially 0-based 2^64 . The first digit of an unsigned integer is 0 , not 1 . So if the maximum value is 1 , it has two possible values: 0

In C Left shift (char) 0xFF by 8 and cast it to int

若如初见. 提交于 2019-11-30 17:45:53
On left shift of (char) 0xff by 8 and casting it to int we get -256 or 0xffffff00. Can somebody explain why this should happen? #include <stdio.h> int main (void) { char c = 0xff; printf("%d %x\n", (int)(c<<8),(int)(c<<8)); return 0; } Output is -256 ffffff00 char can be signed or unsigned - it's implementation-defined. You see these results because char is signed by default on your compiler. For the signed char 0xFF corresponds to −1 (that's how two's complement work). When you try to shift it it is first promoted to an int and then shifted - you effectively get multiplication by 256. So it

Signed 64 by 32 integer division

一个人想着一个人 提交于 2019-11-30 16:03:45
Assuming you have a machine instruction udive that does a special case 64 by 32 unsigned division by taking a (32bit dividend << 32) / 32bit divisor, we can do a full 64 by 32 division using the following: // assume: a / b guaranteed not to overflow a = 64bit dividend, a.h & a.l are hi & lo 32bits respectively b = 32bit divisor q1 = udive(a.h, b) // (a.h << 32) / b r1 = -(q1 * b) // remainder of the above, shortcut since a.h & 0xffffffff == 0 q2 = a.l / b // a.l / b using regular unsigned division r2 = a.l - (q2 * b) // remainder of the above q = q1 + q2 r = r1 + r2 // r < r2, r overflowed and

would doing arithmetic operation on a pair of signed and unsigned numbers be legal?

给你一囗甜甜゛ 提交于 2019-11-30 15:33:19
I'm more than half way through learning assembly and I'm familiar with the concept of how signed and unsigned integers are presented in bits, I know that it might seem a weird question of which the answer would be pretty obvious, but I'm wondering if using an arithmetic operation like addition makes sense for a pair of numbers that one of them is considered signed and the other one unsigned, I've thought of multiple examples like below that will yield a correct result: 10000001 (1-byte integer and considered unsigned, equivalent to 129) + 11111111 (1-byte integer and considered signed(two's

Android Studio Signed APK Not Installing

谁说我不能喝 提交于 2019-11-30 12:43:41
问题 I am in Android Studio and signing an APK under Build > Generate Signed APK and using the wizard. Everything appears to sign fine and an .apk file is generated. When I go copy this file over to my device (either Nexus 7 or Moto X) it won't install. I get an "install failed" message. I can't figure out what's going wrong at all. I have put this .apk up in the google play developer console under "alpha testing" and it was accepted fine (I'm waiting for the tester link to become active to try

How can I do 64-bit arithmetic in Perl?

爷,独闯天下 提交于 2019-11-30 08:56:56
I am a perl newbie, Can I simply use 64-bit arithmetic in Perl? For example $operand1 = 0xFFFFFFFFFFFF; # 48 bit value $operand2 = 0xFFFFFFFFFFFF; # 48 bit value $Result = $operand1 * $operand2; I am basically looking for a replacement for the int64_t in perl. Is there any way to mention, if the variable is signed or unsigned? Yes, however you need to have Perl compiled with 64-bit support. Sinan Ünür See bigint : Transparent BigInteger support for Perl... All operators (including basic math operations) except the range operator .. are overloaded. Integer constants are created as proper

Is subtracting larger unsigned value from smaller in C++ undefined behaviour?

放肆的年华 提交于 2019-11-30 06:01:13
问题 In a program below after "integral promotions" and "usual arithmetic conversions" both operands of operator - remain unsigned long long . Afterwards, C++11 standard says: 5.7.3 The result of the binary - operator is the difference resulting from the subtraction of the second operand from the first. Does the standard define anywhere in more detail how exactly the subtraction is performed (or refers to some other document that defines it)? Does subtracting a larger unsigned integer from smaller

Parser for signed overpunch values?

可紊 提交于 2019-11-30 05:33:01
问题 I am working with some old data imports and came across a bunch of data from an external source that reports financial numbers with a signed overpunch. I've seen alot, but this is before my time. Before I go about creating a function to parse these strangers, I wanted to check to see if there was a standard way to handle these. I guess my question is, does the .Net framework provide a standard facility for converting signed overpunch strings? If not .NET, are there any third party tools I can