Skip to content

Instantly share code, notes, and snippets.

@rjhilgefort
Created September 22, 2022 01:51
Show Gist options
  • Save rjhilgefort/41a3c42eae48779ff0c017a34f711660 to your computer and use it in GitHub Desktop.
Save rjhilgefort/41a3c42eae48779ff0c017a34f711660 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment