Skip to content

Instantly share code, notes, and snippets.

@gustavopsantos
Created March 30, 2023 22:05
Show Gist options
  • Save gustavopsantos/57c2671b2166f5da7626b947549740de to your computer and use it in GitHub Desktop.
Save gustavopsantos/57c2671b2166f5da7626b947549740de to your computer and use it in GitHub Desktop.
public struct Frequency
{
private readonly long _millihertz;
public double Hertz => _millihertz / 1000d;
public TimeSpan Interval => TimeSpan.FromSeconds(1d / Hertz);
public Frequency(long millihertz)
{
_millihertz = millihertz;
}
public static Frequency FromHertz(double hertz)
{
return new Frequency((long) (hertz * 1000));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment