Skip to content

Commit

Permalink
float support
Browse files Browse the repository at this point in the history
  • Loading branch information
gritzko committed Nov 27, 2017
1 parent 5608d24 commit a65f6c2
Show file tree
Hide file tree
Showing 10 changed files with 888 additions and 767 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ RON may express that state as:
```
Those are two RON *ops*:

1. some last-write-wins object has a field `bar` set to `1` (on 2017-10-31 10:26:00 UTC, by gritzko),
2. another object has a field `foo` set to the first object (10:27:00, by gritzko).
1. some last-write-wins object is created with a field `bar` set to `1` (on 2017-10-31 10:26:00 UTC, by gritzko),
2. another object is created with a field `foo` pointing to the first object (10:27:00, by gritzko).

Each op is a tuple of four globally-unique UUIDs for its data type, object, event and location, plus some number of value *atoms*.
You may not see any UUIDs in the above example, initially.
The RON notation does a lot to compress that metadata away.
The notation does a lot to compress that metadata away.

These are the key features of RON:

Expand Down
13 changes: 12 additions & 1 deletion atoms.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,19 @@ func (a Atom) UUID() UUID {
return UUID(a)
}

var BIT32 = uint64(1)<<32
var BIT33 = uint64(1)<<33

func (a Atom) Float() float64 {
return math.Float64frombits(a[0])
pow := int(a[1]&INT32_FULL)
if a[1]&BIT33 != 0 {
pow = -pow
}
ret := float64(a[0]) * math.Pow10(pow)
if a[1]&BIT32 != 0 {
ret = -ret
}
return ret
}

// add JSON escapes
Expand Down
8 changes: 4 additions & 4 deletions bitsep.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package ron
var PUNCT, BITS [128]int8

// bit-separator conversions generated by ./sep2bits.pl on
// Wed Nov 22 00:17:01 +05 2017
// Mon Nov 27 11:41:36 +05 2017
// from
// commit 66bddac49c77bb364f9baa797ffdce62263f07aa
// commit 5608d24e128dc8023af975f0a613508f579ecbcf
// Author: Victor Grishchenko <[email protected]>
// Date: Tue Nov 14 18:00:37 2017 +0500
// Date: Sat Nov 25 17:58:34 2017 +0500
//
// RFC4211 UUID compatibility
// mod frame.AppendXYZ conventions

const SPEC_KIND = 1

Expand Down
Loading

0 comments on commit a65f6c2

Please sign in to comment.