Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Fix parsing/serialization of Timestamp, use fractional seconds instead of nanoseconds #16

Merged
merged 2 commits into from Feb 17, 2022

Conversation

jhurliman
Copy link
Contributor

No description provided.

@@ -1,7 +1,7 @@
import { Participant, selectIPv4, Durability, Reliability, HistoryKind } from "../src";
import { getNetworkInterfaces, UdpSocketNode } from "../src/nodejs";

const DURATION_INFINITE = { sec: 0x7fffffff, nsec: 0xffffffff };
const DURATION_INFINITE = { sec: 0x7fffffff, nsec: 999999999 };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@jhurliman jhurliman merged commit 4c4308f into main Feb 17, 2022
@jhurliman jhurliman deleted the jhurliman/timestamp-parsing branch February 17, 2022 21:37
* @returns Nanoseconds integer
*/
export function fractionToNanoseconds(fraction: number): number {
return Math.trunc(Number((BigInt(fraction) * 1_000_000_000n) / 4_294_967_296n));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of Math.trunc when we just did integer division before converting to Number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I keep forgetting BigInt is actually an integer, not floating-point like Number.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants