Created FloatAttribute precision (markdown)

Richard Townsend 2014-08-09 07:19:15 -07:00
parent dc68418a23
commit d665bd5a42
1 changed files with 15 additions and 0 deletions

@ -0,0 +1,15 @@
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.**
```go
for _, a := range pred.AllAttributes() {
af, ok := a.(*base.FloatAttribute)
if !ok {
panic("All of these should be FloatAttributes!")
}
af.Precision = 1
}
```