format and floating numbers



I have a trivial problem for which I can think of many solutions but I
do not like any of them.

I have some Lisp code that does a lot of computations and generates
files in csv format which are later read by R for plotting and simple
analysis. Unfortunately, it looks like some of my functions (actually
those that read data from database) produce double-float results
and when they are saved they have 'd' as sign of exponent. R just does
not believe that if you can have 'd' in exponent.

So to make these files readable I have few possibilities:
1) coerce return value of each function to single-float (it's ok, I do
not really need all those digits). It is a bother.
2) write some new function instead of format, say eformat which will
coerce all double-floats to single-floats before calling format
3) use sed after I saved the file
4) somehow tell format to use 'e' instead of 'd' for exponent. I have
no Idea how to do it.

If it helps -- I use sbcl 1.0.9

Any simple way of doing it I missed?

Thanks!

.



Relevant Pages

  • Re: format and floating numbers
    ... files in csv format which are later read by R for plotting and simple ... and when they are saved they have 'd' as sign of exponent. ... coerce return value of each function to single-float (it's ok, ...
    (comp.lang.lisp)
  • Re: Representation of values for fastest software floating point processing
    ... normalizations and additions will be a common operation; ... But let's talk about the CDC 6600 format. ... The format of signed-mantissa and biased exponent ... modern standard format with two major differences. ...
    (comp.programming)
  • Re: Standard number format and number of digits
    ... The routine ensures always the maximum number of significant digits, writing the number in all the possible combinations (with or without an exponent) that fit in the requested size and keep the one that is more compact with higher accuracy. ... It could be done something similar for the calculator or it would be easier to declare in the STD format the maximum total number of digits to be displayed? ... sgn = False ...
    (comp.sys.hp48)
  • Re: Fixed-point Math help
    ... > suggestion of using google is probably a good one. ... > can be packed in any format you like or is convenient to you. ... but it is usually assumed for the mantissa at any convenient ... > values of the exponent. ...
    (comp.arch.embedded)
  • Re: format and floating numbers
    ... files in csv format which are later read by R for plotting and simple ... and when they are saved they have 'd' as sign of exponent. ... coerce return value of each function to single-float (it's ok, ...
    (comp.lang.lisp)