# Gauge Math and Formula Reference

**URL:** <https://forum.realdash.net/t/gauge-math-and-formula-reference/8298>\
**Category:** Help, tips and tricks\
**Created:** [May 15, 2025, 9:06am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298 "2025-05-15T09:06:32Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![frongus](https://forum.realdash.net/user_avatar/forum.realdash.net/frongus/32/2040_2.png) [@frongus](https://forum.realdash.net/u/frongus)\
**Post date:** [May 15, 2025, 9:06am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/1 "2025-05-15T09:06:32Z")

</div>

# What is Gauge Math?

_Gauge Math_ are optional math equations which may be used to manipulate input values for display in a gauge. To edit Gauge Math for a specific gauge, select the gauge and go to _Look&Feel_ \> _Special_ \> _Gauge Math_. Click/Tap on the white box and enter your equation. By default – if the field is left empty – this will simply return the input value.

The same syntax is also used for the **Set value (formula)** action, which may be used to calculate values upon trigger activation or a button press. Gauge Math, on the other hand, is performed every time the input value the gauge is linked to is updated.

All math equations must start with **one** equals sign `=`, otherwise the input is considered invalid and the operation will not be performed. This is the same behavior as in spreadsheet applications like Excel.

# Which values/parameters can we use?

Usable parameters are:

- the target ID/value already assigned to the gauge or action. Use `V`to manipulate this value in math equations. _Example:_ if ‘Gauge Math’ is set to `=2*V`, the gauge will always show double the actual input value.
- all other target IDs, prefixed with `ID`. A list of all available target IDs can be found [here](https://realdash.net/manuals/targetid.php). _Example:_ Target ID for ‘Vehicle Speed’ is `ID64`.
- custom values defined in the XML file associated with your dashboard or OBD2/CAN connection, circumfixed with apostrophes `''`. E.g. if `my_value` is defined in the XML file, use `'my_value'`to reference it in math equations.
- any number as a static value, including the constants π (`PI`) and e (`E`).

### Notes:

(1) Certain target IDs, like “Weather: Description (Net)”, or navigation instructions, have pre-defined text outputs. It is best to not manipulate these values using Gauge Math to avoid unintended behavior of gauges using these values.

(2) Target IDs with Boolean values will be handled as integers in Gauge Math: 0 = off/`false` and 1 = on/`true`.

# Which operations can we perform?

**Note:** the list of operators below may be incomplete, as I add all operators beyond the basic ones by trial and error, or referenced from previous forum posts. Feel free to add to this in the comments as well.

| Operation | Description | Parameters | Syntax |
| --- | --- | --- | --- |
| Addition | Add two values | 2 | `A+B` |
| Subtraction | Subtract value B from value A | 2 | `A-B` |
| Multiplication | Multiply two values | 2 | `A*B` |
| Division | Divide value A by value B | 2 | `A/B` |
| Remainder | Subtract B from A until B\>A, then return the remainder of A. (Modulo, A mod B) | 2 | `A%B` |
| Power | Raise A to the Bth power | 2 | `A^B` = `POW(A,B)` |
| Square root | Return square root of A | 1 | `SQRT(A)` = `A^0.5` |
| Natural logarithm | Return the natural logarithm (base e) of A | 1 | `LN(A)` |
| Decimal logarithm | Return the logarithm (base 10) of A | 1 | `LOG(A)` |
| Natural exponential | Return e to the power of A | 1 | `EXP(A)` = `E^A` = `POW(E,A)` |
| Sine | Return sine of A | 1 | `SIN(A)` |
| Cosine | Return cosine of A | 1 | `COS(A)` |
| Tangent | Return tangent of A | 1 | `TAN(A)` |
| Inverse Sine (arcsine) | Return arcsin of A | 1 | `ASIN(A)` |
| Inverse Cosine (arccosine) | Return arccos of A | 1 | `ACOS(A)` |
| Inverse Tangent (arctangent) | Return arctan of A | 1 | `ATAN(A)` |
| Hyperbolic sine | Return sinh of A | 1 | `SINH(A)` |
| Hyperbolic cosine | Return cosh of A | 1 | `COSH(A)` |
| Hyperbolic tangent | Return tanh of A | 1 | `TANH(A)` |
| Round up (ceiling) | Round A up to the nearest integer | 1 | `CEIL(A)` |
| Round down (floor) | Round A down to the nearest integer | 1 | `FLOOR(A)` |
| Absolute value | Return A as an unsigned value | 1 | `ABS(A)` |
| Maximum | Compare values A and B, return the larger one | 2 | `MAX(A,B)` |
| Minimum | Compare values A and B, return the smaller one | 2 | `MIN(A,B)` |
| Pi | Return π = 3.14159… | 0 | `PI` |
| Euler’s number | Return e = 2.71828… | 0 | `E` |

### Notes

(1) other trigonometric functions:

- Cotangent: cot(A) = 1/tan(A)
- Secant: sec(A) = 1/cos(A)
- Cosecant: csc(A) = 1/sin(A)

(2) Roots other than the square root can be calculated using powers, as n√x^m = x^(m/n)

# What about invalid results, i.e. dividing by zero?

If an equation returns an invalid value, i.e. one which cannot be expressed as a real number, the value will be set to –2,147,483,648 (the lowest possible signed 32-bit integer). This behavior will ignore limits set in ‘Input & Values’ and artificial limits set by triggers. I don’t know if this is intentional, but it does serve a purpose as an error indicator.

**Invalid values include:**

- divisions by zero, including:
  - tan(x) when x is an odd multiple of π/2
  - cot(x) when tan(x) = 0
  - sec(x) when cos(x) = 0
  - csc(x) when sin(x) = 0
  - coth(0) = 1/tanh(0) = 1/0

- ln(0) and log(0)
- 0 to the power of 0
- complex numbers (all numbers a + b·i where b ≠ 0; i = √(–1))
- infinity
- text

## I will add to this whenever I have time and find something new. Please leave corrections and suggestions in the comments below.

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [May 16, 2025, 5:54am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/2 "2025-05-16T05:54:31Z")

</div>

Thank you so much for this. This has been requested long time ago, and I never found time to do it.

---

<div class="post-metadata">

**Author:** ![Henri.be](https://forum.realdash.net/user_avatar/forum.realdash.net/henri.be/32/1844_2.png) [@Henri.be](https://forum.realdash.net/u/Henri.be)\
**Post date:** [May 16, 2025, 9:53am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/3 "2025-05-16T09:53:42Z")

</div>

Too bad there are no string functions. Like concatenation, for example.  
Isn’t it possible to include this kind of thing?

This a question for Realdashdev, not for Frongus of course.

Great thanks frongus !!!

… and great thanks too to Realdashdev for sure !!! 🙂

---

<div class="post-metadata">

**Author:** ![frongus](https://forum.realdash.net/user_avatar/forum.realdash.net/frongus/32/2040_2.png) [@frongus](https://forum.realdash.net/u/frongus)\
**Post date:** [May 18, 2025, 7:43am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/4 "2025-05-18T07:43:29Z")

</div>

Ps: Which programming language is RealDash written in? This would help documenting more syntax regarding math functions.

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [May 19, 2025, 5:50am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/5 "2025-05-19T05:50:30Z")

</div>

> [@frongus](#):
>
> Which programming language is RealDash written in?

99% C++, 1% some other platform specific stuff (Java,Kotlin,ObjC etc.)

---

<div class="post-metadata">

**Author:** ![Holywar](https://forum.realdash.net/user_avatar/forum.realdash.net/holywar/32/2241_2.png) [@Holywar](https://forum.realdash.net/u/Holywar)\
**Post date:** [June 18, 2025, 9:44am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/6 "2025-06-18T09:44:23Z")

</div>

I tried to calculate the Dwell value by dividing the Dwell angle value and the rpm using the gauge math function, but if I start the program before the engine starts, it becomes divide by zero and outputs -2.1 billion, and then the parameter no longer works. Of course, if I restart the program, it’s solved, but is there no way to solve this?

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [June 18, 2025, 9:47am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/7 "2025-06-18T09:47:17Z")

</div>

What does your Gauge Math formula look like?

---

<div class="post-metadata">

**Author:** ![frongus](https://forum.realdash.net/user_avatar/forum.realdash.net/frongus/32/2040_2.png) [@frongus](https://forum.realdash.net/u/frongus)\
**Post date:** [June 18, 2025, 9:53am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/8 "2025-06-18T09:53:19Z")

</div>

This may be because there is no value set for the dwell angle or the RPM before the engine is started, thus both values will output 0. Is one of these value in the denominator of a division? In this case, take this value `V` and replace it with `(V+0.001)`. This will avoid division by zero and output a very high value instead, which you can handle with triggers and actions.

I use that, for example, for conversion between l/100km and MPG, l/100km = 235/MPG, as I sometimes want _some_ values to be US units but everything else be metric.

---

<div class="post-metadata">

**Author:** ![Holywar](https://forum.realdash.net/user_avatar/forum.realdash.net/holywar/32/2241_2.png) [@Holywar](https://forum.realdash.net/u/Holywar)\
**Post date:** [June 18, 2025, 9:58am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/9 "2025-06-18T09:58:31Z")

</div>

Dwell Time

=v(ignition dwell) / id37(rpm) / 0.006

---

<div class="post-metadata">

**Author:** ![Holywar](https://forum.realdash.net/user_avatar/forum.realdash.net/holywar/32/2241_2.png) [@Holywar](https://forum.realdash.net/u/Holywar)\
**Post date:** [June 18, 2025, 10:03am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/10 "2025-06-18T10:03:49Z")

</div>

Thanks! +0.001 ! Great Tip!

---

<div class="post-metadata">

**Author:** ![Holywar](https://forum.realdash.net/user_avatar/forum.realdash.net/holywar/32/2241_2.png) [@Holywar](https://forum.realdash.net/u/Holywar)\
**Post date:** [June 18, 2025, 10:19am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/11 "2025-06-18T10:19:38Z")

</div>

[![](https://forum.realdash.net/uploads/default/original/2X/7/7dc078f7aaf1ce46845196b58d24a22b81fa7a79.jpeg "Dwell Time Monitoring in RealDash") ](https://www.youtube.com/watch?v=-vfZksSyj7w)

This is a monitoring clip on BNR32.

---

<div class="post-metadata">

**Author:** ![frongus](https://forum.realdash.net/user_avatar/forum.realdash.net/frongus/32/2040_2.png) [@frongus](https://forum.realdash.net/u/frongus)\
**Post date:** [June 18, 2025, 11:35am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/12 "2025-06-18T11:35:31Z")

</div>

Yes, in this case replace `ID37` with `(ID37+0.001)`. Or, really, any small value, as RPM is in the thousands anyway. The smaller the constant you added is, the higher the value will be when `ID37` is actually 0.

Since RPM isn’t expected to be negative, this should also not cause issues, as adding a constant simply moves the point where division by zero occurs.

---

<div class="post-metadata">

**Author:** ![frongus](https://forum.realdash.net/user_avatar/forum.realdash.net/frongus/32/2040_2.png) [@frongus](https://forum.realdash.net/u/frongus)\
**Post date:** [June 18, 2025, 11:49am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/13 "2025-06-18T11:49:50Z")

</div>

> [@Henri.be](#):
>
> oo bad there are no string functions. Like concatenation, for example.

Concatenation and handling strings would be really nice – as would be `if/else` functions like, for example, in Excel. I don’t know how easy or difficult this is to implement though

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [June 18, 2025, 11:57am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/14 "2025-06-18T11:57:27Z")

</div>

> [@frongus](#):
>
> as would be `if/else` functions

That would require some sort of full scripting engine, which is not a simple task to make run hundreds, sometimes thousands of times per second.

Current math formulas support compare operations =, \>,\<,!= which produce value of 0 or 1. You can actually do quite a lot with these.

---

<div class="post-metadata">

**Author:** ![frongus](https://forum.realdash.net/user_avatar/forum.realdash.net/frongus/32/2040_2.png) [@frongus](https://forum.realdash.net/u/frongus)\
**Post date:** [June 18, 2025, 12:15pm UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/15 "2025-06-18T12:15:59Z")

</div>

Thank you.

For setting different texts, I work around using a placeholder value and the ‘Normal’, ‘Warning’ and ‘Critical’ thresholds to set up to three different strings in a text gauge. For my purpose, having units change between km/h, mph and knots, this is sufficient and easier to handle than math equations.

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [September 10, 2025, 6:14am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/16 "2025-09-10T06:14:56Z")

</div>



---

<div class="post-metadata">

**Author:** ![frongus](https://forum.realdash.net/user_avatar/forum.realdash.net/frongus/32/2040_2.png) [@frongus](https://forum.realdash.net/u/frongus)\
**Post date:** [September 25, 2026, 8:13am UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/17 "2026-09-25T08:13:56Z")

</div>

Sorry for necroing, but I can’t edit the original post anymore.

To elaborate on that:

> [@frongus](#):
>
> **Invalid values include:** […]
> 
> - text

To elaborate on that:

“Text” in this context is any value that is not a number. This type of error happens rarely, but there is one notorious example: the “Current Speed Limit” target ID (`ID67`), which can trigger this error on its own. The reason is that its value stems from the `maxspeed` key from OpenStreetMaps data, whenever `maxspeed=*` without any tags is defined. Two cases result in something that is interpreted by RealDash as a string of text and thus an invalid value:

- when the specified speed limit is tied to further conditions, for example 120 km/h only when its raining, the key would read `maxspeed=120 @ wet`. “120 @ wet” is not a number.
- when a territory’s default speed limits and the key `maxspeed=implicit` are used. “implicit” is not a number.

---

<div class="post-metadata">

**Author:** ![frongus](https://forum.realdash.net/user_avatar/forum.realdash.net/frongus/32/2040_2.png) [@frongus](https://forum.realdash.net/u/frongus)\
**Post date:** [October 12, 2026, 12:30pm UTC](https://forum.realdash.net/t/gauge-math-and-formula-reference/8298/18 "2026-10-12T12:30:14Z")

</div>

PS: another workaround for this is to use triggers. If trigger conditions are met, set a value (for example, “Dash Data 01” (ID 788) to 1, if they’re no longer met, set it to 0. Then, to calculate equation A when the conditions are met, and equation B when they aren’t, use the following:

`=(ID788*(<equation 1>))+((1-ID788)*(<equation 2>))`

For example, if you want add 1 to a value if conditions are met, and subtract 1 if they aren’t met:

`=(ID788*(V+1))+((1-ID788)*(V-1))`

Make sure that this ‘dummy’ value isn’t used anywhere else already, of course.

Also, I found out that gauge math supports the following logical operators for Boolean values `P` and `Q`:

- Logical AND: `P&&Q`

- Logical OR: `P||Q`

- Logical NOT: `NOT(P)`

Such Boolean values are the following comparisons:

- A is equal to B (`A=B` or `A==B`)
- A is not equal to B (`A!=B` or `A<>B`)
- A is greater than B (`A>B`)
- A is less than B (`A<B`)
- A is greater than or equal to B / A is not less than B (`A>=B`)
- A is less than or equal to B / A is not greater than B (`A<=B`)
