In Analysis when using sendData how do you write a floating value

I couldn’t find an example of this.

Here is my sendData filter:

const pulses_per = {

  variable: "gallons_per_sample",

  value: num_pulses_per_sample/pulses_per_gallon,

  unit: "gallons"

};

Will it write a floating value automagically, or do I have to convert to a float?

Thx,

M

Hello @marlanw,

Yes, when you send data, the value field accepts multiple types: string | number | boolean. Your calculation num_pulses_per_sample / pulses_per_gallon will produce a JavaScript number (which includes floating-point values), and TagoIO will store it exactly as calculated.

In some cases, floating-point operations may generate long decimal values. If you want to limit the number of decimal places, you can use the built-in toFixed() method.

const pulses_per = {
  variable: "gallons_per_sample",
  value: Number((num_pulses_per_sample / pulses_per_gallon).toFixed(2)), // e.g., 3.14
  unit: "gallons"
};

Let me know if you need anything else.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.