1 FloatAttribute precision
Richard Townsend edited this page 2014-08-09 07:19:15 -07:00

The Precision field in the FloatAttribute struct controls how many decimal places are used to represent the value when it's converted to a string. This affects the value of GetStringFromSysVal, and hence the value of GetClass, DecomposeOnAttributeValues and every other function which depends on a string class variable.

By default, Precision is set to two.

Code excerpt: Setting the precision of all FloatAttributes on a set of instances to one decimal place.

for _, a := range pred.AllAttributes() {
    af, ok := a.(*base.FloatAttribute)
    if !ok {
       panic("All of these should be FloatAttributes!")
    }
    af.Precision = 1
}