Re: format and floating numbers
- From: smallpond <smallpond@xxxxxxxx>
- Date: Fri, 28 Sep 2007 15:26:57 -0700
On Sep 28, 4:26 pm, "alexey.gol...@xxxxxxxxx"
<alexey.gol...@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?
Thanks!
(setq s (format nil "~18,6,2E" pi))
" 3.141593L+00"
(setf (char s 14) #\E)
#\E
s
" 3.141593E+00"
L is kind of a weird exponent anyway.
--S
.
- References:
- format and floating numbers
- From: alexey.goldin@xxxxxxxxx
- format and floating numbers
- Prev by Date: Re: (not about) Re: How To Learn Lisp
- Next by Date: Re: announcement: FriCAS-1.0.0 release
- Previous by thread: format and floating numbers
- Next by thread: Re: format and floating numbers
- Index(es):
Relevant Pages
|