Skip to content
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

Why the target size in the header is 8 bytes? #232

Closed
z1617 opened this issue Oct 12, 2018 · 1 comment
Closed

Why the target size in the header is 8 bytes? #232

z1617 opened this issue Oct 12, 2018 · 1 comment

Comments

@z1617
Copy link

z1617 commented Oct 12, 2018

-spec integer_to_scientific(integer()) -> sci_int().
integer_to_scientific(I) ->
    %% Find exponent and significand
    {Exp, Significand} = integer_to_scientific(I, 3),
    case Exp >= 0 of
        true ->
            %% 1st byte: exponent, next 3 bytes: significand
            (Exp bsl 24) + Significand;
        false ->
            %% flip sign bit in significand
            ((-Exp) bsl 24) + 16#800000 + Significand
    end.

Since sci_int is 4 bytes as with BTC.

@hanssv
Copy link
Member

hanssv commented Oct 15, 2018

That looks like a copy-paste artifact, 4 bytes should be enough...

This is tracked here https://www.pivotaltracker.com/story/show/161211831

@hanssv hanssv closed this as completed Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants