chiark
/
gitweb
/
~ianmdlvl
/
otter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
171aa53
)
into and from limb
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 4 Oct 2020 19:04:11 +0000
(20:04 +0100)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 4 Oct 2020 19:04:11 +0000
(20:04 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bigfloat.rs
patch
|
blob
|
history
diff --git
a/src/bigfloat.rs
b/src/bigfloat.rs
index 9a6032dba32ee0a00715c0f94f50e1d7ee2f9a3d..aa7bca34e1fe06a7ee2b6cbb9a081e7ac9460c8d 100644
(file)
--- a/
src/bigfloat.rs
+++ b/
src/bigfloat.rs
@@
-122,6
+122,23
@@
mod innards {
}
}
+
+impl From<u64> for Limb {
+ fn from(u: u64) -> Limb {
+ assert_eq!(0, u >> 48);
+ Limb([ ((u >> 32) & 0xffff) as u16,
+ ((u >> 16) & 0xffff) as u16,
+ ((u >> 0) & 0xffff) as u16 ])
+ }
+}
+impl From<Limb> for u64 {
+ fn from(l: Limb) -> u64 {
+ ((l.0[0] as u64) << 32) |
+ ((l.0[1] as u64) << 16) |
+ ((l.0[2] as u64) << 0)
+ }
+}
+
/*/
impl Bigfloat {
fn from_parts(sign: Sign, exp: Sz, limbs: &[Limb]) {