Skip to content

Commit

Permalink
update docs now that Char is not a subtype of Integer
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebolewski committed Oct 27, 2014
1 parent eed3724 commit 3845ca2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
10 changes: 4 additions & 6 deletions doc/manual/conversion-and-promotion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,13 @@ promotion type does not need to be one of the argument types, however;
the following promotion rules both occur in Julia's standard library::

promote_rule(::Type{Uint8}, ::Type{Int8}) = Int
promote_rule(::Type{Char}, ::Type{Uint8}) = Int32
promote_rule(::Type{BigInt}, ::Type{Int8}) = BigInt

As a general rule, Julia promotes integers to `Int` during computation
order to avoid overflow. In the latter case, the result type is
``Int32`` since ``Int32`` is large enough to contain all possible
Unicode code points, and numeric operations on characters always
result in plain old integers unless explicitly cast back to characters
(see :ref:`man-characters`). Also note that one does not need to
define both ``promote_rule(::Type{A}, ::Type{B})`` and
``BigInt`` since ``BigInt`` is the only type large enough to hold
integers for arbitrary-precision integer arithmetic. Also note that one
does not need to define both ``promote_rule(::Type{A}, ::Type{B})`` and
``promote_rule(::Type{B}, ::Type{A})`` — the symmetry is implied by
the way ``promote_rule`` is used in the promotion process.

Expand Down
5 changes: 0 additions & 5 deletions doc/manual/integers-and-floating-point-numbers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,8 @@ Type Signed? Number of bits Smallest value Largest value
``Int128`` ✓ 128 -2^127 2^127 - 1
``Uint128`` 128 0 2^128 - 1
``Bool`` N/A 8 ``false`` (0) ``true`` (1)
``Char`` N/A 32 ``'\0'`` ``'\Uffffffff'``
=========== ======= ============== ============== ==================

``Char`` natively supports representation of
`Unicode characters <http://en.wikipedia.org/wiki/Unicode>`_; see
:ref:`man-strings` for more details.

- **Floating-point types:**

=========== ========= ==============
Expand Down
4 changes: 2 additions & 2 deletions doc/manual/strings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ There are a few noteworthy high-level features about Julia's strings:
can be used in any function expecting a ``String``.
- Like C and Java, but unlike most dynamic languages, Julia has a
first-class type representing a single character, called ``Char``.
This is just a special kind of 32-bit integer whose numeric value
This is just a special kind of 32-bit bitstype whose numeric value
represents a Unicode code point.
- As in Java, strings are immutable: the value of a ``String`` object
cannot be changed. To construct a different string value, you
Expand All @@ -62,7 +62,7 @@ Characters
----------

A ``Char`` value represents a single character: it is just a 32-bit
integer with a special literal representation and appropriate arithmetic
bitstype with a special literal representation and appropriate arithmetic
behaviors, whose numeric value is interpreted as a `Unicode code
point <http://en.wikipedia.org/wiki/Code_point>`_. Here is how ``Char``
values are input and shown:
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ the standard bits types are all defined in the language itself::
bitstype 64 Float64 <: FloatingPoint

bitstype 8 Bool <: Integer
bitstype 32 Char <: Integer
bitstype 32 Char

bitstype 8 Int8 <: Signed
bitstype 8 Uint8 <: Unsigned
Expand Down

0 comments on commit 3845ca2

Please sign in to comment.