annotate test/integer.tst @ 31214:19bd1953fc1d stable

GitHub-CI: Remove ubuntu-18.04 runners from build matrix. * .github/workflow/make.yaml (ubuntu): GitHub-hosted runners for ubuntu-18.04 are being deprecated. Remove them from build matrix. See also: https://github.com/actions/runner-images/issues/6002
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 30 Aug 2022 11:16:27 +0200
parents 796f54d4ddbf
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
3 ## Copyright (C) 2018-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
25835
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
7 ##
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
8 ## This file is part of Octave.
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
9 ##
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
13 ## (at your option) any later version.
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
14 ##
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
18 ## GNU General Public License for more details.
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
19 ##
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
25835
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
25
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
26 ## Test saturation mechanics of lower bound
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
27 %!test
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
28 %! for cls = {"int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64"}
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
29 %! clsmin = intmin (cls{1});
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
30 %! xplus = clsmin + (-1);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
31 %! assert (xplus, clsmin);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
32 %! xminus = clsmin -1;
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
33 %! assert (xminus, clsmin);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
34 %! xmult = clsmin * 2;
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
35 %! assert (xmult, clsmin);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
36 %! xdiv = clsmin / 0.5;
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
37 %! assert (xdiv, clsmin);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
38 %! endfor
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
39
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
40 ## Test saturation mechanics of upper bound
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
41 %!test
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
42 %! for cls = {"int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64"}
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
43 %! clsmax = intmax (cls{1});
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
44 %! xplus = clsmax + 1;
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
45 %! assert (xplus, clsmax);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
46 %! xminus = clsmax - (-1);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
47 %! assert (xminus, clsmax);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
48 %! xmult = clsmax * 2;
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
49 %! assert (xmult, clsmax);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
50 %! xdiv = clsmax / 0.5;
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
51 %! assert (xdiv, clsmax);
4530c5824bbe Add new integer.tst module to test saturation mechanics.
Rik <rik@octave.org>
parents:
diff changeset
52 %! endfor
28589
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
53
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
54 ## Tests for binary constants
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
55 %!assert (0b1, uint8 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
56 %!assert (0b10000000, uint8 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
57 %!assert (0b11111111, intmax ("uint8"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
58 %!assert (0b100000000, uint16 (2^8))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
59 %!assert (0b1000000000000000, uint16 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
60 %!assert (0b1111111111111111, intmax ("uint16"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
61 %!assert (0b10000000000000000, uint32 (2^16))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
62 %!assert (0b10000000000000000000000000000000, uint32 (2^31))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
63 %!assert (0b11111111111111111111111111111111, intmax ("uint32"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
64 %!assert (0b100000000000000000000000000000000, uint64 (2^32))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
65 %!assert (0b1000000000000000000000000000000000000000000000000000000000000000, uint64 (2^63))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
66 %!assert (0b1111111111111111111111111111111111111111111111111111111111111111, intmax ("uint64"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
67 %!error <too many digits for binary constant> eval ("0b11111111111111111111111111111111111111111111111111111111111111111")
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
68
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
69 %!assert (0b1u16, uint16 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
70 %!assert (0b10000000u16, uint16 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
71
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
72 %!assert (0b1u32, uint32 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
73 %!assert (0b10000000u32, uint32 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
74 %!assert (0b1000000000000000u32, uint32 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
75
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
76 %!assert (0b1u64, uint64 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
77 %!assert (0b10000000u64, uint64 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
78 %!assert (0b1000000000000000u64, uint64 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
79 %!assert (0b10000000000000000000000000000000u64, uint64 (2^31))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
80
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
81 %!assert (0b1s16, int16 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
82 %!assert (0b10000000s16, int16 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
83
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
84 %!assert (0b1s32, int32 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
85 %!assert (0b10000000s32, int32 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
86 %!assert (0b1000000000000000s32, int32 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
87
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
88 %!assert (0b1s64, int64 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
89 %!assert (0b10000000s64, int64 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
90 %!assert (0b1000000000000000s64, int64 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
91 %!assert (0b10000000000000000000000000000000s64, int64 (2^31))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
92
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
93 ## Tests for hexadecimal constants
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
94 %!assert (0x1, uint8 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
95 %!assert (0x80, uint8 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
96 %!assert (0xff, intmax ("uint8"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
97 %!assert (0x100, uint16 (2^8))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
98 %!assert (0x8000, uint16 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
99 %!assert (0xffff, intmax ("uint16"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
100 %!assert (0x10000, uint32 (2^16))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
101 %!assert (0x80000000, uint32 (2^31))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
102 %!assert (0xffffffff, intmax ("uint32"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
103 %!assert (0x100000000, uint64 (2^32))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
104 %!assert (0x8000000000000000, uint64 (2^63))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
105 %!assert (0xffffffffffffffff, intmax ("uint64"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
106 %!error <too many digits for hexadecimal constant> eval ("0xfffffffffffffffff")
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
107
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
108 %!assert (0x1u16, uint16 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
109 %!assert (0x80u16, uint16 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
110
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
111 %!assert (0x1u32, uint32 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
112 %!assert (0x80u32, uint32 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
113 %!assert (0x8000u32, uint32 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
114
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
115 %!assert (0x1u64, uint64 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
116 %!assert (0x80u64, uint64 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
117 %!assert (0x8000u64, uint64 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
118 %!assert (0x80000000u64, uint64 (2^31))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
119
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
120 %!assert (0x1s16, int16 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
121 %!assert (0x80s16, int16 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
122
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
123 %!assert (0x1s32, int32 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
124 %!assert (0x80s32, int32 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
125 %!assert (0x8000s32, int32 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
126
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
127 %!assert (0x1s64, int64 (2^0))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
128 %!assert (0x80s64, int64 (2^7))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
129 %!assert (0x8000s64, int64 (2^15))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
130 %!assert (0x80000000s64, int64 (2^31))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
131
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
132 ## Tests for decimal constants with extreme values
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
133
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
134 %!assert (uint64 (9007199254740992), uint64 (flintmax ()))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
135 %!assert (int64 (9007199254740992), int64 (flintmax ()))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
136 %!assert (uint64 (-9007199254740992), uint64 (-flintmax ()))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
137 %!assert (int64 (-9007199254740992), int64 (-flintmax ()))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
138
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
139 %!assert (uint64 (9007199254740993), uint64 (flintmax ())+1)
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
140 %!assert (int64 (9007199254740993), int64 (flintmax ())+1)
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
141 %!assert (uint64 (-9007199254740993), uint64 (-flintmax ())-1)
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
142 %!assert (int64 (-9007199254740993), int64 (-flintmax ())-1)
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
143
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
144 %!assert (uint64 (18446744073709551615), intmax ("uint64"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
145
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
146 %!assert (int64 (9223372036854775807), intmax ("int64"))
d5f9c8911090 * integer.tst: New tests for integer constants.
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
147 %!assert (int64 (-9223372036854775808), intmin ("int64"))
28590
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
148
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
149 %!test
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
150 %! a = int64 ([9223372036854775803; 9223372036854775804; 9223372036854775805; 9223372036854775806; 9223372036854775807]);
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
151 %! bval = int64 (9223372036854775807);
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
152 %! b = [bval; bval; bval; bval; bval];
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
153 %! assert (a, b);
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
154
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
155 %!test
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
156 %! a = int64 ([int64(9223372036854775803); 9223372036854775804; 9223372036854775805; 9223372036854775806; 9223372036854775807]);
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
157 %! b0val = int64 (9223372036854775803);
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
158 %! bval = int64 (9223372036854775807);
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
159 %! b = [b0val; bval; bval; bval; bval];
5b1143d1d74b improve compatibility of concatenation for large integer constants (bug #45945)
John W. Eaton <jwe@octave.org>
parents: 28589
diff changeset
160 %! assert (a, b);