Back to column formats
Column formattingSharePoint Online

Decimal to Binary Conversion

This sample provides decimal conversion to binary using standard List formatting math functions.

Decimal to Binary Conversion formatting preview
Sample preview · View original animation

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "div",
      "style": {
        "display": "flex"
      },
      "children": [
        {
          "elmType": "div",
          "style": {
            "height": "36px",
            "width": "50px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary  ms-fontWeight-bold sp-field-borderAllSolid"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px",
                "text-align": "center",
                "cursor": "pointer"
              },
              "inlineEditField": "@currentField",
              "txtContent": "@currentField"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "margin": "0px 0px",
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary  ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px"
              },
              "txtContent": "="
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px"
              },
              "txtContent": "=(floor(floor(floor(floor(floor(floor(floor(Number(@currentField)/2) /2)/2)/2)/2)/2)/2) % 2"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px"
              },
              "txtContent": "=(floor(floor(floor(floor(floor(floor(Number(@currentField)/2) /2)/2)/2)/2)/2) % 2"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px"
              },
              "txtContent": "=(floor(floor(floor(floor(floor(Number(@currentField)/2) /2)/2)/2)/2) % 2"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px"
              },
              "txtContent": "=(floor(floor(floor(floor(Number(@currentField)/2) /2)/2)/2) % 2"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px"
              },
              "txtContent": "=(floor(floor(floor(Number(@currentField)/2) /2)/2) % 2"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px"
              },
              "txtContent": "=(floor(floor(Number(@currentField)/2) /2) % 2"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px"
              },
              "txtContent": "=(floor(Number(@currentField)/2) % 2"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "height": "40px",
            "width": "20px"
          },
          "attributes": {
            "class": "ms-fontSize-18 ms-bgColor-themeLighter ms-fontColor-themePrimary ms-fontWeight-bold"
          },
          "children": [
            {
              "elmType": "div",
              "style": {
                "padding": "5px 5px"
              },
              "txtContent": "=Number(@currentField) % 2"
            }
          ]
        }
      ]
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample provides decimal conversion to binary using standard List formatting math functions.

screenshot of the sample

View requirements

  • The format expect the following fields:
Field Type
DecimalBinary Number- Define min value of 0 and max value of 255.

Sample

Solution Author(s)
number-decimal-binary.json André Lage

Version history

Version Date Comments
1.0 April 04, 2022 Initial release

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.