Dec2Bin ( decimalNumber ; binaryNumber )
Converts decimal number (positive integer) to binary number
Average rating: 4.3 (35 votes) Log in to vote
Ronald W. Satz Transpower Corporation http://www.transpowercorp.com |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
This custom function converts a base 10 number (a positive integer) to its equivalent base 2 value.
Comments
Vaughan Bromfield Mar 13, 2010 |
||
The function as posted does not compute: "theResult" is not defined before it is used in the Case statement. Also the function returns null if the decimal number is zero. The following changes seems to resolve both issues, but significant; testing has not been performed: -- // Dec2Bin ( decimalNumber ; binaryNumber ) (binaryNumber is initially "") // Converts decimal number to binary number // By Ronald W. Satz // 11-20-2004 Case ( decimalNumber = 0 and IsEmpty( binaryNumber ) ; 0 ; // Exit case for zero decimalNumber = 0 ; binaryNumber ; // Exit Let ( [ theResult = Mod ( decimalNumber ; 2 ) & binaryNumber ; decimalNumber = Int ( decimalNumber / 2 ) ] ; Dec2Bin (decimalNumber; theResult) ) ) // Case |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.