---
url: /dyad/dev/stdlib/BlockComponents/components/Math.BooleanToReal.md
description: Dyad Math.BooleanToReal docs.  Convert Boolean to Real signal.
---

# `Math.BooleanToReal` {#Math.BooleanToReal}

Convert Boolean to Real signal.

This block computes the output `y` as Real equivalent of the Boolean input `u`:

```
y = if u then realTrue else realFalse
```

where `u` is of Boolean and `y` of Real type, and `realTrue` and `realFalse` are parameters.

This component extends from [`BlockComponents.Interfaces.PartialBooleanSI`](../types/Interfaces.PartialBooleanSI.md)

## Usage {#Usage}

`BlockComponents.Math.BooleanToReal(realTrue=1.0, realFalse=0.0)`

## Parameters: {#Parameters:}

|        Name |                           Description | Units | Default value |
| -----------:| -------------------------------------:| -----:| -------------:|
|  `realTrue` |  Output signal for true Boolean input |     – |           1.0 |
| `realFalse` | Output signal for false Boolean input |     – |           0.0 |

## Connectors {#Connectors}

* `u` - This connector represents a boolean signal as an input to a component ([`BooleanInput`](/stdlib/Dyad/connectors/BooleanInput#BooleanInput))

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Behavior {#Behavior}

$$ \begin{align}
y\left( t \right) &= ifelse\left( u\left( t \right), \mathtt{realTrue}, \mathtt{realFalse} \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
Convert Boolean to Real signal.

This block computes the output `y` as Real equivalent of the Boolean input `u`:

```
y = if u then realTrue else realFalse
```

where `u` is of Boolean and `y` of Real type, and `realTrue` and `realFalse` are parameters.
"""
component BooleanToReal
  extends BlockComponents.Interfaces.PartialBooleanSI
  "Connector of Real output signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Output signal for true Boolean input"
  parameter realTrue::Real = 1.0
  "Output signal for false Boolean input"
  parameter realFalse::Real = 0.0
relations
  y = ifelse(u, realTrue, realFalse)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/BooleanToReal.svg"}
  }
}
end
````

````dyad
"""
Convert Boolean to Real signal.

This block computes the output `y` as Real equivalent of the Boolean input `u`:

```
y = if u then realTrue else realFalse
```

where `u` is of Boolean and `y` of Real type, and `realTrue` and `realFalse` are parameters.
"""
component BooleanToReal
  "Connector of Boolean input signal"
  u = BooleanInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of Real output signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Output signal for true Boolean input"
  parameter realTrue::Real = 1.0
  "Output signal for false Boolean input"
  parameter realFalse::Real = 0.0
relations
  y = ifelse(u, realTrue, realFalse)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/BooleanToReal.svg"}
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`BooleanConstant`](Math.BooleanToReal.md)

  * [`BooleanStep`](Math.BooleanToReal.md)

  * [`BooleanToReal`](Math.BooleanToReal.md)

  * [`BooleanToReal`](Math.BooleanToReal.md)

  * [`Constant`](Math.BooleanToReal.md)

  * [`RealToBoolean`](Math.BooleanToReal.md)

  * [`Sine`](Math.BooleanToReal.md)
