---
title: "Calculate deterministic sinh for double in C#"
url: https://recursiveai.org/onemath/cookbook/calculate-deterministic-hyperbolic-sine/
description: "Calculate the hyperbolic sine of a double in C# with OneMath. See what Math64.Sinh returns for ordinary and near-zero inputs, signed zero, and overflow."
version: "1.0.0"
---

# Calculate deterministic sinh for double in C#

**OneMath** is a free, open-source deterministic math library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneMath) · [GitHub](https://github.com/recursive-ai-oss/onemath-csharp) · [Docs](https://recursiveai.org/onemath/docs/) · [Download example (.zip)](https://recursiveai.org/onemath/cookbook/calculate-deterministic-hyperbolic-sine/calculate-deterministic-hyperbolic-sine.zip)

Hyperbolic sine (`sinh`) is almost linear near zero and grows in magnitude as you move away from zero.

```shell
dotnet add package RecursiveAI.OneMath
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneMath;

Console.WriteLine(Math64.Sinh(1));
Console.WriteLine(Math64.Sinh(1e-20));
```

Unzip [the example](https://recursiveai.org/onemath/cookbook/calculate-deterministic-hyperbolic-sine/calculate-deterministic-hyperbolic-sine.zip), then `dotnet run`.

Prints with an English locale:

```text
1.1752011936438014
1E-20
```

## The full program

```csharp
using RecursiveAI.OneMath;

foreach (double x in new[] { 1.0, -1.0, 1e-20, -0.0, 1000.0 })
{
    double result = Math64.Sinh(x);
    ulong bits = BitConverter.DoubleToUInt64Bits(result);
    Console.WriteLine(FormattableString.Invariant(
        $"sinh({x:R}) = {result:R} (0x{bits:X16})"));
}
```

```text
sinh(1) = 1.1752011936438014 (0x3FF2CD9FC44EB982)
sinh(-1) = -1.1752011936438014 (0xBFF2CD9FC44EB982)
sinh(1E-20) = 1E-20 (0x3BC79CA10C924223)
sinh(-0) = -0 (0x8000000000000000)
sinh(1000) = Infinity (0x7FF0000000000000)
```

The full program prints both invariant decimal text and the 64-bit result in hexadecimal. The bits distinguish negative zero from positive zero even in a display that formats them the same way.

Overflow returns signed infinity rather than throwing, and `NaN` input produces `NaN`; use `double.IsFinite` on the result if your calculation requires a finite value.

## Variations

**Return a `float`.** When the rest of your calculation uses single precision, use `Math32.Sinh` for rounding directly to that precision:

```csharp
using RecursiveAI.OneMath;

float result = Math32.Sinh(1f);
Console.WriteLine(result);
```

This prints `1.1752012` with an English locale.

## Related recipes

- [Calculate deterministic tanh](https://recursiveai.org/onemath/cookbook/calculate-deterministic-hyperbolic-tangent/)
- [Calculate exp(x) minus one](https://recursiveai.org/onemath/cookbook/calculate-exp-minus-one/)

## The short answer

Use `Math64.Sinh(x)` for a `double`. OneMath’s [function contract](https://recursiveai.org/onemath/docs/functions/) specifies correct rounding to the nearest representable value, with ties going to the even significand. The same input bits produce the same result bits across platforms. [OneMath promises the same bits across runtimes and CPUs](https://github.com/recursive-ai-oss/onemath-csharp/blob/1986f32ecb9f5f3001c0121484f104c489720334/README.md#L43-L45); [.NET doesn’t make that promise for `System.Math.Sinh`](https://learn.microsoft.com/en-us/dotnet/api/system.math.sinh?view=net-10.0#remarks). Correct rounding doesn’t mean the exact real answer always fits in a `double`: for example, the printed value for `sinh(1)` represents the rounded result.

## What is the difference between sin and sinh?

Ordinary sine oscillates between −1 and 1. Hyperbolic sine doesn’t repeat or have a fixed upper or lower bound: its formula is [(eˣ − e⁻ˣ) / 2](https://archive.lib.msu.edu/crcmath/math/math/h/h409.htm). Changing the sign of `x` changes the sign of `sinh(x)`, as the rows for `1` and `−1` show. The formula also explains why large inputs can overflow: one of the exponentials grows while the other shrinks toward zero.

## What does sinh return near zero?

Close to zero, the two exponentials in the formula are almost equal. If you round each exponential to a `double` before subtracting, they can both become `1` and the subtraction can yield zero for a nonzero input. The [OneMath function reference](https://recursiveai.org/onemath/docs/functions/) documents a higher-precision calculation based on `expm1`, which computes the exponential minus one without first rounding the exponential to a `double`.

For inputs with magnitude below 2⁻²⁷, the function reference says `sinh(x)` rounds back to `x`. That’s why `1e-20` comes back unchanged and negative zero keeps its sign. It doesn’t mean the mathematical `sinh(x)` equals `x` for small nonzero values; the difference is too small to change the rounded result.

## Should I use float or double in C#?

Use `Math64.Sinh` if a saved value, replay, or downstream calculation needs a `double`. Use `Math32.Sinh` if the inputs and results are meant to be single precision. The documented rounding is to the result type; widening a result that was already rounded to `float` doesn’t restore the missing bits. When comparing results across machines, compare the input bits as well: a deterministic function can’t make different inputs agree.
