To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 12510
12509  |  12511
Subject: 
Re: Some comments on LPub
Newsgroups: 
lugnet.cad
Date: 
Sat, 26 Mar 2005 16:39:03 GMT
Viewed: 
1061 times
  
In lugnet.cad, Kevin L. Clague wrote:
In lugnet.cad, Anders Isaksson wrote:
Kevin L. Clague wrote:
    a) For instance, when "l3p_use_seam_width true 0.800000" is in
the config file, then after loading, the seam value appears in LPub
as 0.800000011920929.
[...]
"color_scaling 0.650000 ..." in the config file, it is shown as
36/64% in L3Pub after loading that config, and after saving it, it
is "color_scaling 0.640000 ..." in the config file. Subsequent
"0.996094 0.996094 0.996094".

I will study this problem.  I'm sure that I am just using
sprintf("%f"), and sscanf("%f"), so I'm not sure what to do here.
Anyone out there got ideas on this?

This is exactly what happens when you read string numbers into a float (or
Pascal single) and then convert it to a double (or extended). Floating point
numbers are never exact in computers, and storing them with limited
precision (sprintf("%f")) will not make the situation better.

Anders,
  Thanks very much.  I'll see what I can do.
Kevin

One way to adress this is to keep the setting in memory also as a string, and
never convert on the way of loading a config file into memory and saving it to a
file again. Only when the setting is used to do calculations, it is converted
from the internal string variable to a float or double variable, but it is never
converted back. This guarantees that it does not "move" between load/save
cycles, but the price is you have two internal variables instead of just one.

Andy



Message is in Reply To:
  Re: Some comments on LPub
 
(...) Anders, Thanks very much. I'll see what I can do. Kevin (20 years ago, 22-Mar-05, to lugnet.cad)

10 Messages in This Thread:




Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR