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

re-enable BigInt hexadecimal literals #23546

Merged
merged 6 commits into from
Oct 11, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update "noteworthy differences from C/C++"
  • Loading branch information
rfourquet committed Oct 10, 2020
commit 3691faee5393c435f42d2dea20731d104993114a
8 changes: 5 additions & 3 deletions doc/src/manual/noteworthy-differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,18 @@ For users coming to Julia from R, these are some noteworthy differences:
a larger size type, such as `Int64` (if `Int` is `Int32`), `Int128`, or the arbitrarily large
`BigInt` type. There are no numeric literal suffixes, such as `L`, `LL`, `U`, `UL`, `ULL` to indicate
unsigned and/or signed vs. unsigned. Decimal literals are always signed, and hexadecimal literals
(which start with `0x` like C/C++), are unsigned. Hexadecimal literals also, unlike C/C++/Java
(which start with `0x` like C/C++), are unsigned, unless when they encode more than 128 bits,
in which case they are of type ``BigInt``. Hexadecimal literals also, unlike C/C++/Java
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

``BigInt`` -> `BigInt`

and unlike decimal literals in Julia, have a type based on the *length* of the literal, including
leading 0s. For example, `0x0` and `0x00` have type [`UInt8`](@ref), `0x000` and `0x0000` have type
[`UInt16`](@ref), then literals with 5 to 8 hex digits have type `UInt32`, 9 to 16 hex digits type
`UInt64` and 17 to 32 hex digits type `UInt128`. This needs to be taken into account when defining
`UInt64`, 17 to 32 hex digits type `UInt128`, and more that 32 hex digits type `BigInt`.
This needs to be taken into account when defining
hexadecimal masks, for example `~0xf == 0xf0` is very different from `~0x000f == 0xfff0`. 64 bit `Float64`
and 32 bit [`Float32`](@ref) bit literals are expressed as `1.0` and `1.0f0` respectively. Floating point
literals are rounded (and not promoted to the `BigFloat` type) if they can not be exactly represented.
Floating point literals are closer in behavior to C/C++. Octal (prefixed with `0o`) and binary
(prefixed with `0b`) literals are also treated as unsigned.
(prefixed with `0b`) literals are also treated as unsigned (or `BigInt` for more than 128 bits).
* String literals can be delimited with either `"` or `"""`, `"""` delimited literals can contain
`"` characters without quoting it like `"\""`. String literals can have values of other variables
or expressions interpolated into them, indicated by `$variablename` or `$(expression)`, which
Expand Down