If you want to store floats with less precision you can truncate the
information to the decimal place you like by multiplying by a base 10
factor flooring the result and then dividing by the same factor.
ie |eval(lambda: floor("value" * 100.0)/ 100.0)
May I ask what is the motivation?
The precision on the floats will still be 64bits just that the trailing
digits will all be zero. Are you hoping to get better storage compression
or something?
On Tuesday, October 11, 2016 at 9:01:01 AM UTC-6, [email protected] wrote:
>
> On Tuesday, September 27, 2016 at 9:42:05 PM UTC+1, Ross McDonald wrote:
> > Is this just for display purposes (using it in a message), or do you
> want to store the value like that? You can use `printf` in a template for
> changing the precision, for example:
> >
> > ```
> >
> > |alert()
> >
> > .message('Percentage value is {{ index .Fields "value" | printf "%0.2f"
> }}%')
> > ```
> >
> >
> > I'm not sure if there's a way to store the value that way, though.
> >
> >
> >
> > On Mon, Sep 26, 2016 at 10:35 PM, guotao Yao <[email protected]> wrote:
> >
> > Hi all,
> >
> >
> > The next are statements of tick script, I want to get a percentage
> value.
> >
> >
> > ```
> >
> > |eval(lambda: float(100) * ("system.value" / "total.value"))
> > .as('value')
> > ```
> >
> >
> > Result value:
> > 6.3636355999903165
> >
> >
> >
> > I want to get a value like this: 6.36.
> >
> >
> > In other words, I need to control the precision of the float value.
> >
> >
> > What should I do?
> >
> >
> > Thanks!
> >
> >
> >
> >
> > --
> >
> > Remember to include the InfluxDB version number with all issue reports
> >
> > ---
> >
> > You received this message because you are subscribed to the Google
> Groups "InfluxDB" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected].
> >
> > To post to this group, send email to [email protected].
> >
> > Visit this group at https://groups.google.com/group/influxdb.
> >
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/influxdb/2a3d1590-fc14-4842-a1e1-b569c2925bec%40googlegroups.com.
>
>
> >
> > For more options, visit https://groups.google.com/d/optout.
>
> how to store this calculated percentage in influxdb using tick script?
--
Remember to include the InfluxDB version number with all issue reports
---
You received this message because you are subscribed to the Google Groups
"InfluxDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit
https://groups.google.com/d/msgid/influxdb/86aadcd2-da9c-48aa-820e-609c1533c041%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.