trustgraph / trustgraph-holochain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Normalize `value` in TrustAtom

harlantwood opened this issue · comments

Feature:

link tag when complete looks like:

Ŧ→sushi[0x00].900000000[0x00]892412523[0x00]uhCEk…UFnFF
Ŧ→sushi[0x00]-.900000000[0x00]892412523[0x00]uhCEk…UFnFF

This feature is to normalize the rating part eg:

.900000000

AC:

  • no leading zero
  • always nine digits after decimal place
  • negatives start with -
  • max is .999999999 (never 1.0)
  • min is -.999999999 (never -1.0)
  • tests

Examples:

  • passing in 0.9 yields .900000000
  • passing in 1.0 yields .999999999

Impl:

  • values come in as strings
  • "zero pad" the input number
  • special case: 1 -> .999999999, -1 -> -.999999999