Difference between revisions of "Base Conversion Function Library"
Line 1: | Line 1: | ||
− | |||
− | The Base Conversion Function Library provides functions for converting between binary, octal, decimal and | + | The Base Conversion Function Library provides functions for converting between binary, octal, decimal and hexadecimal representations of numbers. The functions operate equivalently to the functions with the same names in Excel. |
− | {| | + | :{|class="wikitable" |
− | | | + | ! !! colspan=4|Source ▶ |
|- | |- | ||
− | + | ! Target ▼ !! Bin !! Oct !! Dec !! Hex | |
|- | |- | ||
− | | | + | ! Bin |
+ | | || Oct2Bin(x, ''places'') || Dec2Bin(x, ''places'') || Hex2Bin(x, ''places'') | ||
|- | |- | ||
− | | | + | ! Oct |
+ | | Bin2Oct(x, ''places'') || || Dec2Oct(x, ''places'') || Hex2Oct(x, ''places'') | ||
+ | |- | ||
+ | ! Dec | ||
+ | | Bin2Dec(x) || Oct2Dec(x) || || Hex2Dec(x) | ||
+ | |- | ||
+ | ! Hex | ||
+ | | Bin2Hex(x, ''places'') || Oct2Hex(x, ''places') || Dec2Hex(x, ''places'') || | ||
|} | |} | ||
Line 17: | Line 24: | ||
For binary, octal and hexidecimal values, negative numbers are represented in 2's complement notation with a minimum of 10 digits. This means that the most significant (left-most) bit is the sign bit and is set for negative numbers. Non-decimal numbers having fewer than 10 digits are interpreted as positive. | For binary, octal and hexidecimal values, negative numbers are represented in 2's complement notation with a minimum of 10 digits. This means that the most significant (left-most) bit is the sign bit and is set for negative numbers. Non-decimal numbers having fewer than 10 digits are interpreted as positive. | ||
− | The optional | + | The optional «places» parameter specifies the minimum number of decimal places in the result. For negative numbers, this is ignored. |
− | = Using the Library = | + | == Using the Library == |
− | To use these functions in your model, you must add the [[media:Base Conversion Library.ana|Base Conversion Library.ana]] library to your model. This library uses functions that are new to Analytica 4.1, and thus requires at least Analytica 4.1 to use. To add, select '''File→Add Library...''' and find the [[media:Base Conversion Library.ana|Base Conversion Library.ana]] file. If this isn't already in your Libraries directory, then you can download it here: [[media:Base Conversion Library.ana|Base Conversion Library.ana]]. | + | To use these functions in your model, you must add the [[media:Base Conversion Library.ana|Base Conversion Library.ana]] library to your model. This library uses functions that are new to Analytica 4.1, and thus requires at least Analytica 4.1 to use. To add, select '''File → Add Library...''' and find the [[media:Base Conversion Library.ana|Base Conversion Library.ana]] file. If this isn't already in your Libraries directory, then you can download it here: [[media:Base Conversion Library.ana|Base Conversion Library.ana]]. |
After selecting, you can select either embedded or linked. Once added, the library appears on your definition menu and the functions may be used. | After selecting, you can select either embedded or linked. Once added, the library appears on your definition menu and the functions may be used. | ||
+ | |||
+ | ==History== | ||
+ | Introduced in Analytica 4.1. | ||
+ | |||
+ | ==See Also== | ||
+ | * [[Binary and hexadecimal integer formats]] | ||
+ | * [[Number Format Dialog]] | ||
+ | * [[NumberFormat|NumberFormat]] attribute | ||
+ | * [[ParseNumber]] | ||
+ | * [[NumberToText]] |
Revision as of 22:51, 26 January 2016
The Base Conversion Function Library provides functions for converting between binary, octal, decimal and hexadecimal representations of numbers. The functions operate equivalently to the functions with the same names in Excel.
Source ▶ Target ▼ Bin Oct Dec Hex Bin Oct2Bin(x, places) Dec2Bin(x, places) Hex2Bin(x, places) Oct Bin2Oct(x, places) Dec2Oct(x, places) Hex2Oct(x, places) Dec Bin2Dec(x) Oct2Dec(x) Hex2Dec(x) Hex Bin2Hex(x, places) Oct2Hex(x, places') Dec2Hex(x, places)
The conversions to Decimal all return numeric values, while all other conversions return text.
For binary, octal and hexidecimal values, negative numbers are represented in 2's complement notation with a minimum of 10 digits. This means that the most significant (left-most) bit is the sign bit and is set for negative numbers. Non-decimal numbers having fewer than 10 digits are interpreted as positive.
The optional «places» parameter specifies the minimum number of decimal places in the result. For negative numbers, this is ignored.
Using the Library
To use these functions in your model, you must add the Base Conversion Library.ana library to your model. This library uses functions that are new to Analytica 4.1, and thus requires at least Analytica 4.1 to use. To add, select File → Add Library... and find the Base Conversion Library.ana file. If this isn't already in your Libraries directory, then you can download it here: Base Conversion Library.ana.
After selecting, you can select either embedded or linked. Once added, the library appears on your definition menu and the functions may be used.
History
Introduced in Analytica 4.1.
Enable comment auto-refresher