Created FloatAttribute precision (markdown)
parent
dc68418a23
commit
d665bd5a42
|
@ -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
|
||||
}
|
||||
```
|
||||
|
Loading…
Reference in New Issue