This function is for you, the 2nd parameter is the wanted decimals (obviously from 0 to 3):
This is for float 8bit.8bit
Expected input value are on big-endian ("0x" . #15 . #14)
The input values can be any between 0x0 and 0xffff
test for positive temperature:(0x19a1)/256 = 25.628 C
test for negative temperature: (0xe65f)/256 = -25.628 C
:global float2deg do={
:local float [:tonum $1]
:local decimalsign "," ; # in Italy it is "," in other countries can be "."
:local sign "" ; # if wanted can be "+"
:if ($float > 32767) do={:set float (($float - 65536) * -1); :set sign "-"}
:local forthousand ($float * 1000)
:local forthousand ($forthousand / 256) ; # MikroTik offset
:local ftstring "00$[:tostr $forthousand]"
:local pickpos ([:len $ftstring] - 3)
:local decimals [:pick $ftstring $pickpos ($pickpos + [:tonum $2])]
:local celsius ($forthousand/1000)
:if ([:tonum $2] > 0) do={:set celsius "$celsius$decimalsign$decimals" }
:return "$sign$celsius"
}
Terminal:
[rex@tended] > :global float2deg do={
{... :local float [:tonum $1]
{... :local decimalsign "," ; # in Italy it is "," in other countries can be "."
{... :local sign "" ; # if wanted can be "+"
{... :if ($float > 32767) do={:set float (($float - 65536) * -1); :set sign "-"}
{... :local forthousand ($float * 1000)
{... :local forthousand ($forthousand / 256) ; # MikroTik offset
{... :local ftstring "00$[:tostr $forthousand]"
{... :local pickpos ([:len $ftstring] - 3)
{... :local decimals [:pick $ftstring $pickpos ($pickpos + [:tonum $2])]
{... :local celsius ($forthousand/1000)
{... :if ([:tonum $2] > 0) do={:set celsius "$celsius$decimalsign$decimals" }
{... :return "$sign$celsius"
{... }
[rex@tended] > :put [$float2deg 0x19a1 0]
25
[rex@tended] > :put [$float2deg 0x19a1 1]
25,6
[rex@tended] > :put [$float2deg 0x19a1 2]
25,62
[rex@tended] > :put [$float2deg 0x19a1 3]
25,628
[rex@tended] > :put [$float2deg 0xe65f 0]
-25
[rex@tended] > :put [$float2deg 0xe65f 1]
-25,6
[rex@tended] > :put [$float2deg 0xe65f 2]
-25,628
[rex@tended] > :put [$float2deg 0xe65f 3]
-25,628