问题
I want to read multiple data files (10 in total) in Ansys Fluent. I wrote a journal file which uses scheme language
(Do ((count 11.100 (+ count 0.100))) ((>= count 12.000))
(ti-menu-load-string (format #f "file read-data data-~a.dat" count)))
The format of the file name is like data-11.200.dat
, but the program reads it as data-11.2.dat
. How I can force it to read the floating point numbers after the decimal point?
Of course I can rename the data files, but that is not useful for I have to use the code many times.
I have tried data-~03d.dat
, but that didn't work!
回答1:
Try this:
(do ((count 111/10 (+ count 1/10))) ((>= count 12))
(ti-menu-load-string
(format #f "file read-data data-~2,3F.dat" count)))
I assume format
is from SRFI-48 Intermediate Format Strings. I've changed the numbers to rational numbers because adding 0.1
gives you rounding errors in floating point.
回答2:
I think I have figured that out:
data-~.3f.dat
来源:https://stackoverflow.com/questions/47822902/evaluating-a-floating-point-variable-in-scheme-language