node-opcua-basic-types
Advanced tools
Comparing version 2.1.0 to 2.1.1
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; | ||
export declare function isValidFloat(value: any): boolean; | ||
export declare function roundToFloat2(float: number): number; | ||
export declare type Float = number; | ||
@@ -5,0 +4,0 @@ export declare function randomFloat(): Float; |
@@ -27,24 +27,2 @@ "use strict"; | ||
exports.isValidFloat = isValidFloat; | ||
function roundToFloat2(float) { | ||
if (float === 0) { | ||
return float; | ||
} | ||
// this method artificially rounds a float to 7 significant digit in base 10 | ||
// Note: | ||
// this is to overcome the that that Javascript doesn't provide single precision float values (32 bits) | ||
// but only double precision float values | ||
// wikipedia:(http://en.wikipedia.org/wiki/Floating_point) | ||
// | ||
// * Single precision, usually used to represent the "float" type in the C language family | ||
// (though this is not guaranteed). This is a binary format that occupies 32 bits (4 bytes) and its | ||
// significand has a precision of 24 bits (about 7 decimal digits). | ||
// * Double precision, usually used to represent the "double" type in the C language family | ||
// (though this is not guaranteed). This is a binary format that occupies 64 bits (8 bytes) and its | ||
// significand has a precision of 53 bits (about 16 decimal digits). | ||
// | ||
const nbDigits = Math.ceil(Math.log(Math.abs(float)) / Math.log(10)); | ||
const scale = Math.pow(10, -nbDigits + 2); | ||
return Math.round(float * scale) / scale; | ||
} | ||
exports.roundToFloat2 = roundToFloat2; | ||
const r = new Float32Array(1); | ||
@@ -51,0 +29,0 @@ function roundToFloat(float) { |
{ | ||
"name": "node-opcua-basic-types", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "pure nodejs OPCUA SDK - module -basic-types", | ||
@@ -21,8 +21,8 @@ "main": "./dist/index.js", | ||
"node-opcua-nodeid": "^2.1.0", | ||
"node-opcua-status-code": "^2.1.0", | ||
"node-opcua-utils": "^2.1.0", | ||
"node-opcua-status-code": "^2.1.1", | ||
"node-opcua-utils": "^2.1.1", | ||
"underscore": "^1.9.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^12.6.2", | ||
"@types/node": "^12.6.6", | ||
"@types/underscore": "^1.9.2", | ||
@@ -47,3 +47,3 @@ "node-opcua-debug": "^2.1.0", | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "ddce2b6e3e13371510e63d839c1a4c4ff0be2c15" | ||
"gitHead": "672816a1babe8c9347f85e47cf4e947f4749507e" | ||
} |
@@ -30,25 +30,2 @@ /*** | ||
export function roundToFloat2(float: number): number { | ||
if (float === 0) { | ||
return float; | ||
} | ||
// this method artificially rounds a float to 7 significant digit in base 10 | ||
// Note: | ||
// this is to overcome the that that Javascript doesn't provide single precision float values (32 bits) | ||
// but only double precision float values | ||
// wikipedia:(http://en.wikipedia.org/wiki/Floating_point) | ||
// | ||
// * Single precision, usually used to represent the "float" type in the C language family | ||
// (though this is not guaranteed). This is a binary format that occupies 32 bits (4 bytes) and its | ||
// significand has a precision of 24 bits (about 7 decimal digits). | ||
// * Double precision, usually used to represent the "double" type in the C language family | ||
// (though this is not guaranteed). This is a binary format that occupies 64 bits (8 bytes) and its | ||
// significand has a precision of 53 bits (about 16 decimal digits). | ||
// | ||
const nbDigits = Math.ceil(Math.log(Math.abs(float)) / Math.log(10)); | ||
const scale = Math.pow(10, -nbDigits + 2); | ||
return Math.round(float * scale) / scale; | ||
} | ||
const r = new Float32Array(1); | ||
@@ -55,0 +32,0 @@ |
Sorry, the diff of this file is not supported yet
57
90976
1835
Updatednode-opcua-utils@^2.1.1