UNPKG

node-red-contrib-double

Version:

Node-RED node to parse decimal and binary numbers to IEEE-754 Double Precision Floating Point Numbers

68 lines (63 loc) 2.61 kB
<script type="text/javascript"> RED.nodes.registerType('toDouble', { category: 'function', color: '#FFAAAA', defaults: { name: { value: "" }, toFixed: { value: "" } }, inputs: 1, outputs: 1, icon: "arrow-in.png", label: function () { return this.name || "toDouble"; } }); </script> <script type="text/x-red" data-template-name="toDouble"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-toFixed"><i class="icon-tag"></i> Decimal digits</label> <input type="number" id="node-input-toFixed" placeholder="Example 1: 0.1 - 2: 0.01"> </div> </script> <script type="text/x-red" data-help-name="toDouble"> <p>Converts Binary Strings and Decimals Digits (64 bit) into IEEE-754 Double Precision Floating Point numbers. Works also with arrays.</p> <h3>Inputs</h3> <dl class="message-properties"> <dt>payload <span class="property-type"> string | Int </span> </dt> <dd> the number or the array of numbers to decode in Float 64 bit. </dd> <dt class="optional">Decimals Number <span class="property-type">Number</span></dt> <dd> max digits you want to keep after the '.'.</dd> </dl> <h3>Outputs</h3> <ol class="node-ports"> <li>Standard output <dl class="message-properties"> <dt>payload <span class="property-type">Number | Array</span></dt> <dd>the standard output of the command.</dd> </dl> </li> <li>Standard error <dl class="message-properties"> <dt>payload <span class="property-type">string</span></dt> <dd>the standard error of the command.</dd> </dl> </li> </ol> <h3>Details</h3> <p><code>msg.payload</code> must be an Integer 64 bit or a Binary string like '0100000000001001001000011111101101010100010001000010110100011000' (3.141592653589793) if the type is wrong an error is returned, if the input is an Array the index of the wrong element is returned with the error. <p>Decimals digits can be configured in the node or if left blank the numbers will not be truncated</p> <h3>References</h3> <ul> <li><a href="https://github.com/luigonsec/node-red-contrib-double">GitHub</a> - the node github repository</li> </ul> </script>