Re: format and floating numbers
- From: Waldek Hebisch <hebisch@xxxxxxxxxxxxxxxx>
- Date: Sat, 29 Sep 2007 00:39:04 +0000 (UTC)
alexey.goldin@xxxxxxxxx <alexey.goldin@xxxxxxxxx> wrote:
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?
You may look at *read-default-float-format*:
* (defparameter a 2.78d0)
A
* a
2.78d0
* (setf *read-default-float-format* 'double-float)
DOUBLE-FLOAT
* a
2.78
* (setf a 2.78d30)
2.78e30
*
--
Waldek Hebisch
hebisch@xxxxxxxxxxxxxxxx
.
- References:
- format and floating numbers
- From: alexey.goldin@xxxxxxxxx
- format and floating numbers
- Prev by Date: Re: announcement: FriCAS-1.0.0 release
- Next by Date: Re: (not about) Re: How To Learn Lisp
- Previous by thread: Re: format and floating numbers
- Index(es):
Relevant Pages
|