D
Dr J R Stockton
Recent threads about errors in implementations of Number.toString(Radix)
and the lack of an ECMA parseFloat(String, Radix) are now probably lost
to most of you among the spam; hence this new one.
I have a new page <URL:http://www.merlyn.demon.co.uk/js-exact.htm>. It
currently contains a list of links to those sections of the site which
deal with Exact Arithmetic and Strings; in time, I intend to move those
parts into the page (page js-maths.htm, at least, is now too long). The
list is currently :-
* JavaScript Maths :-
o Some Exact Conversions :-
+ Fixed-Point Radix String to Number
+ Fixed-Point Radix String to Another Radix
* JavaScript Miscellany 0 :-
o Bit Representations of Number :-
+ Number to Four Bytes as Int32 or Dword
+ Float Conversion and Demonstration Code :-
# This Code
# These Forms
# Number to Four Bytes as IEEE Single and Back
# Number to Four Words as IEEE Double and Back
The code does not use the major ECMA Global Functions, just simple exact
integer operations on Numbers, and so is very probably free of imported
bugs and browser dependencies. It does not consider exponents in the
strings. It is intended to be accurate. It is not intended to be fast.
Fixed-Point Radix String to Number should always give the nearest
Number, with the half-way case being rounded away from zero. It can be
used for testing versions previously presented here in CLJ.
Fixed-Point Radix String to Another Radix keeps adding digits after the
radical point until the least significant bit of the least significant
digit is worth less than the LSB of the LSD of the input.
and the lack of an ECMA parseFloat(String, Radix) are now probably lost
to most of you among the spam; hence this new one.
I have a new page <URL:http://www.merlyn.demon.co.uk/js-exact.htm>. It
currently contains a list of links to those sections of the site which
deal with Exact Arithmetic and Strings; in time, I intend to move those
parts into the page (page js-maths.htm, at least, is now too long). The
list is currently :-
* JavaScript Maths :-
o Some Exact Conversions :-
+ Fixed-Point Radix String to Number
+ Fixed-Point Radix String to Another Radix
* JavaScript Miscellany 0 :-
o Bit Representations of Number :-
+ Number to Four Bytes as Int32 or Dword
+ Float Conversion and Demonstration Code :-
# This Code
# These Forms
# Number to Four Bytes as IEEE Single and Back
# Number to Four Words as IEEE Double and Back
The code does not use the major ECMA Global Functions, just simple exact
integer operations on Numbers, and so is very probably free of imported
bugs and browser dependencies. It does not consider exponents in the
strings. It is intended to be accurate. It is not intended to be fast.
Fixed-Point Radix String to Number should always give the nearest
Number, with the half-way case being rounded away from zero. It can be
used for testing versions previously presented here in CLJ.
Fixed-Point Radix String to Another Radix keeps adding digits after the
radical point until the least significant bit of the least significant
digit is worth less than the LSB of the LSD of the input.