nv-facutil-f64
v1.0.21
Published
nv-facutil-f64 ======================= - this util is ONLY should be USED in repl OR compile-time script, coz its very slow - to test compile-time float validate in nvlang, normally USELESS(just use parseFloat) - nvlang NOT support runtime-float, ONLY
Downloads
36
Readme
nv-facutil-f64
- this util is ONLY should be USED in repl OR compile-time script, coz its very slow
- to test compile-time float validate in nvlang, normally USELESS(just use parseFloat)
- nvlang NOT support runtime-float, ONLY support compile-time float
install
- npm install nv-facutil-f64
usage
const x = require("nv-facutil-f64");
example
cls
// view can be used to verify IF your double implement IS same as JS
> var vw = x.creat_view(0.0)
> vw
View [0 : 0_00000000000_0000000000000000000000000000000000000000000000000000] {}
> vw.f64_mant
0n
> vw.f64_mant = 1
1
> vw
View [5e-324 : 0_00000000000_0000000000000000000000000000000000000000000000000001] {}
>
> vw.f64_mant = 2
2
> vw
View [1e-323 : 0_00000000000_0000000000000000000000000000000000000000000000000010] {}
>
> vw.f64_mant = 3
3
> vw
View [1.5e-323 : 0_00000000000_0000000000000000000000000000000000000000000000000011] {}
>
> vw.f64_expo
0
> vw.f64_expo =1
1
> vw
View [2.225073858507203e-308 : 0_00000000001_0000000000000000000000000000000000000000000000000011] {}
>
>
> vw.u8a_rhex
'0706050403020100'
> vw.u8a_lhex
'0001020304050607'
>
funcs
> x.get_desc(3.1)
{
sign: 1n,
bfr_dot: 3n,
aft_dot: [ 225179981368525n, 2251799813685248n ]
}
>
>>> 225179981368525 / 2251799813685248
0.10000000000000009
>>>
> x.get_desc(Number.MIN_VALUE)
{
sign: 1n,
bfr_dot: 0n,
aft_dot: [
1n,
202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784n
]
}
nv-facutil-f64# python3
Python 3.6.9 (default, Nov 25 2022, 14:10:45)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 / 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784
5e-324
>>>
> Number.MAX_VALUE
1.7976931348623157e+308
> x.get_desc(Number.MAX_VALUE)
{
sign: 1n,
bfr_dot: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n,
aft_dot: [ 0n, 1n ]
}
> '179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368'.length -1
308
>
> x.show_buf(5e-324)
'0_00000000000_0000000000000000000000000000000000000000000000000001'
>
> x.set_mantissa_at(5e-324,0,2)
1e-323
>
> x.show_buf(1e-323)
'0_00000000000_0000000000000000000000000000000000000000000000000010'
> x.set_mantissa_at(5e-324,0,255)
1.26e-321
> x.show_buf(1.26e-321)
'0_00000000000_0000000000000000000000000000000000000000000011111111'
>
> x.set_mantissa(5e-324,2n**52n-1n)
2.225073858507201e-308
>
> x.show_buf(5e-324)
'0_00000000000_0000000000000000000000000000000000000000000000000001'
>
> x.show_buf(2.225073858507201e-308)
'0_00000000000_1111111111111111111111111111111111111111111111111111'
>
>
METHODS
View
vw.ab vw.desc vw.dv vw.f32_0 vw.f32_1
vw.f32a vw.f64 vw.f64_expo vw.f64_mant vw.f64_mant_0 vw.f64_mant_1
vw.f64_mant_2 vw.f64_mant_3 vw.f64_mant_4 vw.f64_mant_5 vw.f64_mant_6 vw.f64_sign
vw.f64_str vw.f64a vw.get_f64_mant_at vw.i16_0 vw.i16_1 vw.i16_2
vw.i16_3 vw.i16a vw.i32_0 vw.i32_1 vw.i32a vw.i64
vw.i64a vw.i8_0 vw.i8_1 vw.i8_2 vw.i8_3 vw.i8_4
vw.i8_5 vw.i8_6 vw.i8_7 vw.i8a vw.negify_f64 vw.posify_f64
vw.set_f64_mant_at vw.u16_0 vw.u16_1 vw.u16_2 vw.u16_3 vw.u16a
vw.u32_0 vw.u32_1 vw.u32a vw.u64 vw.u64a vw.u8_0
vw.u8_1 vw.u8_2 vw.u8_3 vw.u8_4 vw.u8_5 vw.u8_6
vw.u8_7 vw.u8a vw.u8a_lhex vw.u8a_rhex vw.u8ca
APIS
{
from_buf: [Function: from_buf],
get_buf: [Function: get_buf],
_show_buf: [Function: _show_buf],
show_buf: [Function: show_buf],
_get_sign: [Function: _get_sign],
get_sign: [Function: get_sign],
_set_sign_to_pos: [Function: _set_sign_to_pos],
_set_sign_to_neg: [Function: _set_sign_to_neg],
set_sign_to_pos: [Function: set_sign_to_pos],
set_sign_to_neg: [Function: set_sign_to_neg],
_get_expo: [Function: _get_expo],
get_expo: [Function: get_expo],
_set_expo: [Function: _set_expo],
set_expo: [Function: set_expo],
_get_mantissa: [Function: _get_mantissa],
get_mantissa: [Function: get_mantissa],
_get_mantissa_at: [Function: _get_mantissa_at],
get_mantissa_at: [Function: get_mantissa_at],
_set_mantissa_at: [Function: _set_mantissa_at],
set_mantissa_at: [Function: set_mantissa_at],
_set_mantissa: [Function: _set_mantissa],
set_mantissa: [Function: set_mantissa],
HIDDEN_1_VAL: 4503599627370496n,
DENOMINATOR_IF_EXPO_IS_ZERO: 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784n,
_get_desc: [Function: _get_desc],
get_desc: [Function: get_desc]
LICENSE
- ISC