|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I've just used #write to write a variable with the value 11.23302 to a file, but
when I open the resulting file it contains only 11.233 .
Any ideas why that is?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 16/03/2014 3:30 PM, FNH wrote:
> I've just used #write to write a variable with the value 11.23302 to a file, but
> when I open the resulting file it contains only 11.233 .
>
> Any ideas why that is?
>
>
Did you define the BINARY_WORD_TYPE?
See: 3.3.2.3.4 The write Directive
--
Regards
Stephen
I solemnly promise to kick the next angle, I see.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Stephen <mca### [at] aolcom> wrote:
> On 16/03/2014 3:30 PM, FNH wrote:
> > I've just used #write to write a variable with the value 11.23302 to a file, but
> > when I open the resulting file it contains only 11.233 .
> >
> > Any ideas why that is?
> >
> >
> Did you define the BINARY_WORD_TYPE?
That will only write the integral part of the value as raw binary bytes.
It has nothing to do with the accuracy of the ascii representation of
floating point values.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 16/03/2014 4:47 PM, Warp wrote:
> That will only write the integral part of the value as raw binary bytes.
> It has nothing to do with the accuracy of the ascii representation of
> floating point values.
Strike that, then. :-(
--
Regards
Stephen
I solemnly promise to kick the next angle, I see.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I've just used #write to write a variable with the value 11.23302 to a file, but
> when I open the resulting file it contains only 11.233 .
>
> Any ideas why that is?
>
>
Just make sure that you actualy write up to 5 decimal places if you
want/need 5 decimal places. Take a look at the str(A,L,P) function. make
sure that P is at least 5.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"FNH" <nomail@nomail> wrote:
> I've just used #write to write a variable with the value 11.23302 to a file,
> but when I open the resulting file it contains only 11.233 .
>
By default, POV-Ray writes only 6 significant figures (if that's the correct
phrase), at least in 32-bit POV-Ray.
Example:
#declare R = seed(52);
#fopen XYZ "test_file.txt" write
#write(XYZ,rand(R))
#fclose XYZ
..... this writes 0.943483
But this...
#write(XYZ,500 + rand(R))
..... writes 500.943 -- still 6 figures, with the final digit rounded off.
As Alain says, the way to get more decimal places is to use str()-- or vstr() if
you're writing vectors:
Like this:
#write(XYZ,str(500 + rand(R),0,12)
..... which writes 500.943482920049 -- 12 actual decimal places.
Or, for a vector,
#write(XYZ,"<",vstr(3,<rand(R),rand(R),rand(R)>,",",0,8),">") // 8 decimals
..... with the result being <0.94348292,0.53555440,0.92402154>
As far as I know, #read reads back exactly what was written-- no more, no less.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Kenneth" <kdw### [at] gmailcom> wrote:
>
> Like this:
> #write(XYZ,str(500 + rand(R),0,12)
> ..... which writes 500.943482920049 -- 12 actual decimal places.
>
DAMN, I left off the final parenthesis there (even after double-checking my
syntax!!) Sorry! (It will cause POV-Ray to hard-crash... mea culpa...)
It should be...
#write(XYZ,str(500 + rand(R),0,12))
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
>
> >
> > Like this:
> > #write(XYZ,str(500 + rand(R),0,12)
> > ..... which writes 500.943482920049 -- 12 actual decimal places.
> >
>
> DAMN, I left off the final parenthesis there (even after double-checking my
> syntax!!) Sorry! (It will cause POV-Ray to hard-crash... mea culpa...)
>
Hmm, it actually doesn't crash, it just causes a fatal error.
(This *does* cause a crash: #write(XYZ,500 + rand(R) // no final parenthesis
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |