Proposal: an integer-nanosecond time type in Brutal.Core/Types

bubbysitch

New Member
Messages
1
Reaction score
0
Hello!! I'm pretty new around here so I hope this being my first post isn't bad! I came from the repo. I'm thinking of putting together a PR for a nanosecond time/duration type and wanted to see if its worth it:)

The plan is a readonly record struct backed by a 64-bit signed integer, living in Brutal.Core/Types/ right alongside ByteSize and ElementCount. It'd follow the exact same pattern: a single Value, explicit conversions, and checked on narrowing

Why add this?
The KSA changelog mentions moving toward integer nanosecond time for universe time, plus a 64-bit BubbleTime for physics steps. Having a dedicated type in Core gives the whole shebang one shared representation instead of passing raw longs or doubles across boundaries. (plus a double starts losing single-nanosecond precision after 2^53 ns:o

What the API would look like:
  • FromSeconds(double) with a clear rounding rule
  • ToSeconds() with a documented error bound
  • Basic math & comparison: +, -, unary -, ordering, plus checked add and negate
  • Constants: Zero, MinValue, MaxValue
Tests I'd include:
  • FromSeconds midpoint rounding behavior
  • ToSeconds round-trip accuracy and where it drifts past 1 ns (since double spacing passes 1 ns at 2^23 seconds, or ~97 days)
  • Checked overflow on addition and negating MinValue
  • Ordering with negative durations
  • Rejecting NaN and infinity
Questions:3
1. Does Brutal.Core/Types feel like the right pklace for this?
2. Is there an existing testing framework?
3. Is a straight nanosecond long fine, or rather make it generic over the time unit?

Should be zero new dependencies! I use cloud AI agents as well! I review the output and do the best I can to show my work through excessively (I mean it) rigorous conformance. Nice to meet you all!<3

harriett
 
Hi there @bubbysitch, thanks for taking an interest in helping out with building BRUTAL!

This is definitely on our list of things to do, but we haven't prioritized it yet. I'd be happy to see a PR containing what you're thinking of, but our gut tells us we'd be quite opinionated on it so there's a non-zero chance we might want to take it in a different direction.

That said: if we took notes from any part of your PR, we'd 100% be happy to add you as a co-author on the final product!
 
Back
Top