Skip to main content
8 events
when toggle format what by license comment
Nov 20, 2020 at 23:48 vote accept BustedSanta
Nov 20, 2020 at 18:34 comment added Jim D @miracle173 your interpretation is correct. I believe BustedSanta was trying to show an intermediate step as an unsigned integer, which is not really relevant in this case as there is no need to convert to base 10 to do the conversion. I think hex, octal, or binary notation is best for these types of problems because the mapping to individual bits is clear (e.g. the sign bit in this case). I would have preferred to express the mask value in my answer as hex, but Oracle (AFAIK) does not allow hex literals.
Nov 20, 2020 at 16:17 comment added miracle173 @BustedSanta I think your interpretation is strange: if you interpret 8508 as signed 16 bit number, then it is a negative number, not a positive one. The singed 16 bit numbers are the decimals between −32768 and +32767. 34056 is not in this interval
Nov 20, 2020 at 10:11 comment added Jim D @miracle173: your algorithm won't work. If you use hex 0000, your algorithm yields -65536 instead of the correct answer of 0.
Nov 20, 2020 at 7:51 comment added miracle173 hex: 8508 > dec: 34056 according to ncalculators.com/digital-computation/hex-decimal-converter.htm . 34056-65536=-31480, 65536 is power(2,16)
Nov 20, 2020 at 3:34 answer added Jim D timeline score: 1
Nov 20, 2020 at 2:21 comment added Jim D Arbitrary word size or 16 bit as per your example?
Nov 20, 2020 at 1:44 history asked BustedSanta CC BY-SA 4.0