Oleg Kobchenko wrote:
> 
> What would be the J equivalent to Javascript
> 
>    11259375.071111083.toString(16)
> abcdef.123456
> 
> That is the "inverse" of
> 
>    0j10 ": 16babcdef.123456
> 11259375.0711110830
> 
Short and unsatisfactory answer would be: "it depends on 
what abcdef.123456 means."  It is presumably a floating 
point (FP) number, but in which representation?

Of course, all this is IEEE standardized nowadays, but your 
example reminds me of a FORTRAN programming course I took 
some long time ago where I learned that FP numbers are 
represented in base 16.

I'd like then to contribute a bit of code for the LAPACK 
add-on for J, namely a call to LAPACK's DLAMCH function in
the following small file '~addons/math/lapack/dlamch.ijs' ,
based on your '~addons/math/lapack/lapack.ijs'

------------------------------------------------------->cut here<---------
NB.  dlamch  determines double precision machine parameters.

coclass'jlapack'

NB.  Use: double dlamch p  (function)
NB.
NB.  p is a character or a string (only the first letter is important.)
NB.  The function returns a double-precision value corresponding 
NB.  to the parameter p (see dlamchAll below.)

dlamch=: 3 : 0
if.{.y e.'EeSsBbPpNnRrMmUuLlOo'do.
  >{.(dll,'dlamch_ + d *')cd {.,each y
else.
  error y;'not a valid argument for dlamch.'
end.
)

dlamchAll=: 3 : 0  NB.
  p=:,:'Eps -- relative machine precision'
  p=:p,'Safe minimum, such that 1/sfmin does not overflow'
  p=:p,'Base of the machine'
  p=:p,'Precision (Eps*Base)'
  p=:p,'Number of (base) digits in the mantissa'
  p=:p,'Rnd -- (1.0 when rounding occurs in addition, 0.0 otherwise)'
  p=:p,'Minimum exponent before (gradual) underflow (emin)'
  p=:p,'Underflow threshold - Base**(emin-1)'
  p=:p,'Largest exponent before overflow'
  p=:p,'Overflow threshold  - (Base**emax)*(1-Eps)'
  (] ; dlamch_jlapack_)"1 p
)
------------------------------------------------------->cut here<---------

   NB. One session:

   require '~addons/math/lapack/lapack.ijs'
   require '~addons/math/lapack/dlamch.ijs'
   dlamch_jlapack_'b'   NB. Base
2
   dlamch_jlapack_'n'   NB. Number of bits in mantissa.
53
   dlamchAll_jlapack_'' NB. Gives a table (not shown here)

-- 
View this message in context: 
http://www.nabble.com/Format-fractional-hexadecimal-tf4895825s24193.html#a14032838
Sent from the J Programming mailing list archive at Nabble.com.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to