Skip to content

FloatAttribute precision

Richard Townsend edited this page Aug 9, 2014 · 1 revision

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
}
Clone this wiki locally