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

Fix conversion from any ints to uint24 and int24 #41

Merged
merged 1 commit into from
Feb 5, 2020

Conversation

rixed
Copy link
Contributor

@rixed rixed commented Feb 4, 2020

int24 was wrong on 64bits arch only, whereas uint24 was wrong for all
archs.

NOTICE: this fix assumes that the previous fix re. uint24 is merged already. Otherwise, conversion to uint24 are still bogus (although less so).

Before:

  # Uint24.(of_uint32 (Uint32.of_int 42) |> to_int);;
  - : int = 10752
  # Int24.(of_int32 (Int32.of_int 42) |> to_int);;
  - : int = 10752

After:

  # Uint24.(of_uint32 (Uint32.of_int 42) |> to_int);;
  - : int = 42
  # Uint24.(of_uint32 (Uint32.of_int 42) |> to_int);;
  - : int = 42

Closes #40

(cherry picked from commit 142ce47)

int24 was wrong on 64bits arch only, whereas uint24 was wrong for all
archs.

Before:

  # Uint24.(of_uint32 (Uint32.of_int 42) |> to_int);;
  - : int = 10752
  # Int24.(of_int32 (Int32.of_int 42) |> to_int);;
  - : int = 10752

After:

  # Uint24.(of_uint32 (Uint32.of_int 42) |> to_int);;
  - : int = 42
  # Uint24.(of_uint32 (Uint32.of_int 42) |> to_int);;
  - : int = 42

Closes andrenth#40

(cherry picked from commit 142ce47)
@rgrinberg rgrinberg merged commit 2e1b477 into andrenth:master Feb 5, 2020
@rixed rixed deleted the fix-40 branch February 10, 2020 20:40
rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Oct 28, 2020
CHANGES:

## Fixes:

* Correct conversion from uint24 to other ints (andrenth/ocaml-stdint#39, @rixed)
* Fix conversion from all ints to uint24 and int24 (andrenth/ocaml-stdint#41, @rixed)
* Fix int24 failing to recover from casts (andrenth/ocaml-stdint#43, @rixed)
* Fix sign extensions (andrenth/ocaml-stdint#49, @rixed)
* `Long_val` returns `intnat`, previously `long` was used (andrenth/ocaml-stdint#53, @dra27)
* Reduce size of marshalled custom values on 4.08+ (andrenth/ocaml-stdint#54, @dra27)
* Store 128-bit ints as structs to prevent unaligned access (andrenth/ocaml-stdint#55, @dra27)

## New features:

* Add `of_substring` (andrenth/ocaml-stdint#49, @darlentar)
rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Oct 28, 2020
CHANGES:

## Fixes:

* Correct conversion from uint24 to other ints (andrenth/ocaml-stdint#39, @rixed)
* Fix conversion from all ints to uint24 and int24 (andrenth/ocaml-stdint#41, @rixed)
* Fix int24 failing to recover from casts (andrenth/ocaml-stdint#43, @rixed)
* Fix sign extensions (andrenth/ocaml-stdint#49, @rixed)
* `Long_val` returns `intnat`, previously `long` was used (andrenth/ocaml-stdint#53, @dra27)
* Reduce size of marshalled custom values on 4.08+ (andrenth/ocaml-stdint#54, @dra27)
* Store 128-bit ints as structs to prevent unaligned access (andrenth/ocaml-stdint#55, @dra27)

## New features:

* Add `of_substring` (andrenth/ocaml-stdint#49, @darlentar)
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

Successfully merging this pull request may close these issues.

More erroneous conversions from uint24 and int24 from all other int types
2 participants