Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Import Macro Repair
Panel
bgColor#ffffff
titleQ

How can a UINT32 value represeting a float value been decoded as float in javascript?

Panel
bgColor#ffffff
titleA

Supposing you are using an existing display from the templates such as "ATVISE/Default/Number/in_out_value", then you can extend it with a function
from http://stackoverflow.com/questions/4414077/read-write-bytes-of-float-in-js named "Bytes2Float32()" to convert the UINT32 integer value to a float value.

function
 Bytes2Float32(bytes) { 

    var sign = (bytes & 0x80000000) ? -1 : 1; 

    var exponent = ((bytes >> 23) & 0xFF) - 127; 

    var significand = (bytes & ~(-1 << 23)); 

     if (exponent == 128) 

        return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY); 

     if (exponent == -127) { 

        if (significand == 0) return sign * 0.0; 

        exponent = -126; 

        significand /= (1 << 22); 

    } else significand = (significand | (1 << 23)) / (1 << 23); 

    return sign * significand * Math.pow(2, exponent); 

}

Example: Feed the function with the value 0x42c83852 for example and it returns the value 100.11

Panel
bgColor#ffffff
titleSee also...

Filter by label (Content by label)
showLabelsfalse
spaces@selfcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@3bbaf8c
showSpacefalse
operatorlabelsfloatAND
labelsatvise data
cqllabel = "atvise" and label = "data" and space = currentSpace ( )