-
Notifications
You must be signed in to change notification settings - Fork 31
add encoding / parsing of real values #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
was the suite faulty, or was there a compelling reason not to support the type uniformly? |
Wasn't clear what the errors from the suite were. Fixed now. |
I guess I need to squash before merging ;-) |
* TC8 returns an error instead of printing the suggested warning * TC17 returns same error as TC15: no need to check all three conditions when we know one is already wrong...
Try rebasing on master |
merged w/ current master |
I am trying to use this library for ember. running on a 64bit os... and the results I get from the real parsing are strangely wrong. I have reimplemented the exact style used here... but I am not sure if it is different from what this library tries to achieve.... Any Inputs ? I can get my code into a pr at some point, for now I am fine using the Bytes() function and continue with custom parsing.... |
EG: Parse as -80.0 While I expect them to parse as -20.... |
Can you explain how you get to The contents of tests/tc10.ber (0x09, 0x07, 0x83, 0x04, 0xff, 0xff, 0xff, 0xfb, 0x05) parse correctly as 0.156250 with func TestRealDecoding(t *testing.T) {
dec, err := DecodePacketErr([]byte{0x09, 0x07, 0x83, 0x04, 0xff, 0xff, 0xff, 0xfb, 0x05})
if err != nil {
t.Errorf("Failed to decode: %s", err)
}
if dec.Value.(float64) != 0.156250 {
t.Errorf("invalid value parsed in tc10: %f <=> 0.156250", dec.Value.(float64))
}
} so the algorythm to decode the binary encoding should be correct. |
see also #46 |
I am by no means an expert, but the code here is well structured and explained using references to the X.690 standard. It might make some use case (ember+) specific assumptions. But since this is the code that I work against I have now copied its behavior line by line and got a working result... |
This does not cover all test cases from the suite. TC8 returns an error instead of a warning, but I think that's ok.