Skip to content

Instantly share code, notes, and snippets.

@rjhilgefort
Created September 22, 2022 01:51
Show Gist options
  • Select an option

  • Save rjhilgefort/41a3c42eae48779ff0c017a34f711660 to your computer and use it in GitHub Desktop.

Select an option

Save rjhilgefort/41a3c42eae48779ff0c017a34f711660 to your computer and use it in GitHub Desktop.

Revisions

  1. rjhilgefort created this gist Sep 22, 2022.
    10 changes: 10 additions & 0 deletions offsetString_from_number
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    const isNegative = (num) => Math.sign(num) === -1
    const isPositive = (num) => Math.sign(num) === 1 || Math.sign(num) === 0

    const offsetString_from_number = (data) => {
    const data_ = Math.abs(data).toString().padStart(2, '0').concat(':').padEnd(5, '0')

    return isNegative(data) ? `-${data_}` : `+${data_}`
    }
    offsetString_from_number(-5)
    offsetString_from_number(+5)