add morphisms
- unicode - value delimited seq - zigzag encoding (still lacking any way to get to signed integer yet'..)
This commit is contained in:
parent
630948139b
commit
d0118b56b1
3 changed files with 190 additions and 0 deletions
morphisms
26
morphisms/zigzag.morphism-base
Normal file
26
morphisms/zigzag.morphism-base
Normal file
|
@ -0,0 +1,26 @@
|
|||
```
|
||||
```
|
||||
|
||||
morph_i64_as_twos_complement_to_zigzag ()
|
||||
ℤ ~ x86.Int64
|
||||
--> ℤ ~ ZigZagInt ~ ℕ ~ x86.UInt64
|
||||
```
|
||||
if( *src >= 0 ) {
|
||||
*dst = (2 * (uint64_t)*src)
|
||||
} else {
|
||||
*dst = (2 * (uint64_t)(- *src)) - 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
```
|
||||
|
||||
morph_i64_as_zigzag_to_twos_complement ()
|
||||
ℤ ~ ZigZagInt ~ ℕ ~ x86.UInt64
|
||||
--> ℤ ~ x86.Int64
|
||||
```
|
||||
if( *src % 2 == 0 ) {
|
||||
*dst = *src / 2;
|
||||
} else {
|
||||
*dst = - ((*src+1) / 2);
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue