Brian Dunning's FileMaker Custom Functions

Dec2Bin9 ( decnum )

Converts a decimal number to its binary equivalent.

  Average rating: 4.6 (30 votes) Log in to vote

M S Pease   M S Pease

Share on Facebook Share on Twitter

  Sample input:
Dec2Bin9 ( 511 )
  Sample output:
111111111

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Non-recursive function to convert a decimal number to its binary equivalent, currently to 9 places (decimal 511 max).

The other "Dec2Bin" custom function didn't work for me, so I formulated this version. It is very simple to edit this function to accommodate larger decimal inputs, or limit it to smaller inputs. I needed nine binary places, so this is the result, named "Dec2Bin9".

 

Comments

comment   comment, VR
Oct 6, 2011
It is very simple to construct a function to accommodate ANY decimal input:

DecToBin ( decimal )

Let ( [
next = Div ( decimal ; 2 )
] ;
Case ( next ; DecToBin ( next ) )
&
Mod ( decimal ; 2 )
)


See also:
http://www.briandunning.com/cf/218
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.