Monday 26 March 2012

Hex Mode Limitation and Behavior

Calculator in "Hex" (hexadecimal) approach cannot acquire or affectation a hexadecimal amount beyond than 0xFFFFFFFFFFFFFFFF (decimal 18446744073709551615). That 8-byte (64-bit) limit, accumulated with absence of notification to the user apropos the limitation or how it is handled, presents a austere dysfunctionality. For example, if the user switches to "Hex" mode, and afresh types "10", and afresh presses the "x^y" button, and afresh types "10" again, and afresh presses "=" the aftereffect will be "0".

That approach alternative and keystroke arrangement agency Calculator is getting told to appraise 16 (decimal) aloft to the 16th (decimal) power, and to affectation the aftereffect in hexadecimal base. In "Hex" mode, on a beneath bound calculator, "10" "x^y" "10" "=", would aftermath 10000000000000000, which is the hexadecimal representation of X'10' ** X'10'. That amount is 17 digits long, and in "Hex" mode, Calculator is bound to registering and announcement no added than 16 hexadecimal digits. In "Hex" mode, if a aftereffect is beyond than can be represented in 16 hexadecimal digits, Calculator will acknowledgment a 0 and crop no absurdity message.

No amount what accumulation abject one may be using, in that base, "10" is the amount of the base. Taking to its own ability the amount of any accumulation abject after-effects in a amount which is in that abject a 1 followed by a amount of 0s according to the amount of the base. So behindhand of what accumulation abject one is using, if one keys "10" "x^y" "10" "=", one should get a 1 followed by a amount of 0s that is according to the amount of the abject one is using.

That works accomplished in Calculator for binary, octal, and decimal modes. Application "Bin" (binary) the user gets 100 (a 1 followed by 2 0s, i.e. abject 2). Application "Oct" (octal) the user gets 100000000 (a 1 followed by 8 0s, i.e. abject 8). Application "Dec" (decimal) the user gets 10000000000 (a 1 followed by 10 0s, i.e. abject 10). But if the user tries to do that application "Hex" mode, the user gets a 0.

In hexadecimal, a 10 represents the amount that in decimal is represented by 16. If the user selects "Dec" mode, and types "16" and afresh presses the "x^y" button and afresh types "16" again, and afresh presses "=" the aftereffect will be (decimal) 18446744073709551616, which is correct, as that is the decimal amount for "16 aloft to the 16th power". Calculator is able of announcement that amount in decimal, but it is butterfingers of announcement in hexadecimal any amount greater than or according to that number.

If the user seeing that amount displayed switches to "Hex" mode, "0" will arise on the resultant display, and if the user afresh switches aback to "Dec" mode, "0" will still appear. That is due to the 16 hexadecimal chiffre limitation imposed in "Hex" mode, and to the adjustment called for administration numbers which cannot be represented in 16 hexadecimal digits. The best was fabricated to artlessly acting aught for any amount greater than 0xFFFFFFFFFFFFFFFF.

In "Dec" mode, Calculator is bound to 32 digits in aftereffect displays. If a user operating Calculator in "Dec" approach produces a aftereffect that exceeds the decimal amount resultant affectation limitations of Calculator, Calculator will resort to Scientific Notation, i.e. it will accurate the amount as a between-1-and-10 amount (sometimes across-the-board of a decimal point and of numerals afterwards the decimal point) times ten to some power. So, for example, Calculator in "Dec" mode, can affectation Avogadro's Amount as 602214179000000000000000 (that amount is additional or bare about 30 in the atomic cogent nonzero digits) which is a 24 chiffre number, but if the user squares that, the aftereffect is 3.62661917388644041e+47. That would be a 48 chiffre amount if it were displayed after the e+ notation. Calculator will not do annihilation akin to the e+ characters in "Hex" mode. It just letters any amount beyond than 16 bytes as 0.

No comments:

Post a Comment