Skip to content

Commit

Permalink
A trivial change.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuina committed Apr 17, 2020
1 parent ab57904 commit cb1931c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package/sys/lib.kn
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ end func
+func [d0000.knd, _same] same(n1: float, n2: float): bool
end func

+func toBit64Forcibly(x: float): bit64
+func [d0000.knd, _toBit64Forcibly] toBit64Forcibly(x: float): bit64
end func

+func toFloatForcibly(x: bit64): float
+func [d0000.knd, _toFloatForcibly] toFloatForcibly(x: bit64): float
end func

+func [d0000.knd, _toRad] toRad(degree: float): float
Expand Down
10 changes: 10 additions & 0 deletions src/lib_common/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,16 @@ EXPORT U64 _addr(SClass* me_)
return (U64)me_;
}

EXPORT U64 _toBit64Forcibly(double x)
{
return *(U64*)&x;
}

EXPORT double _toFloatForcibly(U64 x)
{
return *(double*)&x;
}

void LibInit(void)
{
// Initialize the random number system.
Expand Down
2 changes: 2 additions & 0 deletions src/lib_common/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ EXPORT S64 _addChkOverflow(Bool* overflowed, S64 n1, S64 n2);
EXPORT S64 _subChkOverflow(Bool* overflowed, S64 n1, S64 n2);
EXPORT S64 _mulChkOverflow(Bool* overflowed, S64 n1, S64 n2);
EXPORT U64 _addr(SClass* me_);
EXPORT U64 _toBit64Forcibly(double x);
EXPORT double _toFloatForcibly(U64 x);

void LibInit(void);

Expand Down

0 comments on commit cb1931c

Please sign in to comment.