Table of Contents

Class FixedChronicleTime

Namespace
FixedMathSharp.Chronicler
Assembly
FixedMathSharp.Chronicler.dll

Converts between fixed-point seconds and Chronicler durations and counts complete simulation steps.

public static class FixedChronicleTime
Inheritance
FixedChronicleTime
Inherited Members

Remarks

Both representations use 32 fractional bits. For long-running timelines, subtract timestamps in Chronicler's wide representation before converting their difference.

Methods

FromFixed64(Fixed64)

Widens Fixed64 seconds without rounding or losing fractional bits.

public static ChronicleDuration FromFixed64(Fixed64 value)

Parameters

value Fixed64

A signed duration in seconds. The full Fixed64 range is accepted.

Returns

ChronicleDuration

The exact Chronicler duration.

GetFrameCountForDuration(Fixed64, Fixed64)

Counts complete fixed-duration steps that fit in the supplied duration.

public static long GetFrameCountForDuration(Fixed64 duration, Fixed64 stepDuration)

Parameters

duration Fixed64

The total duration in seconds, from zero through MaxValue.

stepDuration Fixed64

The duration in seconds of one step. This must be positive.

Returns

long

The number of complete steps, rounded down.

Remarks

The quotient uses the raw fixed-point values, including any rounding already present in the inputs.

Exceptions

ArgumentOutOfRangeException

The duration is negative or the step duration is not positive.

ToFixed64(ChronicleDuration)

Converts a duration to Fixed64 seconds exactly, without saturation.

public static Fixed64 ToFixed64(ChronicleDuration value)

Parameters

value ChronicleDuration

The signed duration to convert.

Returns

Fixed64

The exact duration in seconds.

Exceptions

OverflowException

The duration is outside the Fixed64 range.

TryToFixed64(ChronicleDuration, out Fixed64)

Attempts to convert a Chronicler duration to fixed-point seconds.

public static bool TryToFixed64(ChronicleDuration value, out Fixed64 result)

Parameters

value ChronicleDuration

The signed duration to convert.

result Fixed64

The exact duration in seconds on success, or Zero on failure.

Returns

bool

true if the duration fits in Fixed64, otherwise false.