| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * A random-access sequence of bytes that also provides random access to | 6 * A random-access sequence of bytes that also provides random access to |
| 7 * the fixed-width integers and floating point numbers represented by | 7 * the fixed-width integers and floating point numbers represented by |
| 8 * those bytes. Byte arrays may be used to pack and unpack data from | 8 * those bytes. Byte arrays may be used to pack and unpack data from |
| 9 * external sources (such as networks or files systems), and to process | 9 * external sources (such as networks or files systems), and to process |
| 10 * large quantities of numerical data more efficiently than would be possible | 10 * large quantities of numerical data more efficiently than would be possible |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 // TODO(lrn): Change the signature to match String.substring. | 28 // TODO(lrn): Change the signature to match String.substring. |
| 29 /** | 29 /** |
| 30 * Returns a [ByteArray] _view_ of a portion of this byte array. | 30 * Returns a [ByteArray] _view_ of a portion of this byte array. |
| 31 * The returned byte array consists of [length] bytes starting | 31 * The returned byte array consists of [length] bytes starting |
| 32 * at position [start] in this byte array. The returned byte array | 32 * at position [start] in this byte array. The returned byte array |
| 33 * is backed by the same data as this byte array. In other words, | 33 * is backed by the same data as this byte array. In other words, |
| 34 * changes to the returned byte array are visible in this byte array | 34 * changes to the returned byte array are visible in this byte array |
| 35 * and vice-versa. | 35 * and vice-versa. |
| 36 * | 36 * |
| 37 * Throws [IndexOutOfRangeException] if [start] or [length] are negative, or | 37 * Throws [RangeError] if [start] or [length] are negative, or |
| 38 * if `start + length` is greater than the length of this byte array. | 38 * if `start + length` is greater than the length of this byte array. |
| 39 * | 39 * |
| 40 * Throws [ArgumentError] if [length] is negative. | 40 * Throws [ArgumentError] if [length] is negative. |
| 41 */ | 41 */ |
| 42 ByteArray subByteArray([int start, int length]); | 42 ByteArray subByteArray([int start, int length]); |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Returns the (possibly negative) integer represented by the byte at the | 45 * Returns the (possibly negative) integer represented by the byte at the |
| 46 * specified [byteOffset] in this byte array, in two's complement binary | 46 * specified [byteOffset] in this byte array, in two's complement binary |
| 47 * representation. The return value will be between -128 and 127, inclusive. | 47 * representation. The return value will be between -128 and 127, inclusive. |
| 48 * | 48 * |
| 49 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 49 * Throws [RangeError] if [byteOffset] is negative, or |
| 50 * greater than or equal to the length of this byte array. | 50 * greater than or equal to the length of this byte array. |
| 51 */ | 51 */ |
| 52 int getInt8(int byteOffset); | 52 int getInt8(int byteOffset); |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Sets the byte at the specified [byteOffset] in this byte array to the | 55 * Sets the byte at the specified [byteOffset] in this byte array to the |
| 56 * two's complement binary representation of the specified [value], which | 56 * two's complement binary representation of the specified [value], which |
| 57 * must fit in a single byte. In other words, [value] must be between | 57 * must fit in a single byte. In other words, [value] must be between |
| 58 * -128 and 127, inclusive. | 58 * -128 and 127, inclusive. |
| 59 * | 59 * |
| 60 * Returns `byteOffset + 1`, which is the offset of the first byte in the | 60 * Returns `byteOffset + 1`, which is the offset of the first byte in the |
| 61 * array after the byte that was set by this call. This return value can | 61 * array after the byte that was set by this call. This return value can |
| 62 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 62 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 63 * | 63 * |
| 64 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 64 * Throws [RangeError] if [byteOffset] is negative, or |
| 65 * greater than or equal to the length of this byte array. | 65 * greater than or equal to the length of this byte array. |
| 66 * | 66 * |
| 67 * Throws [ArgumentError] if [value] is less than -128 or | 67 * Throws [ArgumentError] if [value] is less than -128 or |
| 68 * greater than 127. | 68 * greater than 127. |
| 69 */ | 69 */ |
| 70 int setInt8(int byteOffset, int value); | 70 int setInt8(int byteOffset, int value); |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * Returns the positive integer represented by the byte at the specified | 73 * Returns the positive integer represented by the byte at the specified |
| 74 * [byteOffset] in this byte array, in unsigned binary form. The | 74 * [byteOffset] in this byte array, in unsigned binary form. The |
| 75 * return value will be between 0 and 255, inclusive. | 75 * return value will be between 0 and 255, inclusive. |
| 76 * | 76 * |
| 77 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 77 * Throws [RangeError] if [byteOffset] is negative, or |
| 78 * greater than or equal to the length of this byte array. | 78 * greater than or equal to the length of this byte array. |
| 79 */ | 79 */ |
| 80 int getUint8(int byteOffset); | 80 int getUint8(int byteOffset); |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * Sets the byte at the specified [byteOffset] in this byte array to the | 83 * Sets the byte at the specified [byteOffset] in this byte array to the |
| 84 * unsigned binary representation of the specified [value], which must fit | 84 * unsigned binary representation of the specified [value], which must fit |
| 85 * in a single byte. in other words, [value] must be between 0 and 255, | 85 * in a single byte. in other words, [value] must be between 0 and 255, |
| 86 * inclusive. | 86 * inclusive. |
| 87 * | 87 * |
| 88 * Returns `byteOffset + 1`, which is the offset of the first byte in the | 88 * Returns `byteOffset + 1`, which is the offset of the first byte in the |
| 89 * array after the byte that was set by this call. This return value can | 89 * array after the byte that was set by this call. This return value can |
| 90 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 90 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 91 * | 91 * |
| 92 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, | 92 * Throws [RangeError] if [byteOffset] is negative, |
| 93 * or greater than or equal to the length of this byte array. | 93 * or greater than or equal to the length of this byte array. |
| 94 * | 94 * |
| 95 * Throws [ArgumentError] if [value] is negative or | 95 * Throws [ArgumentError] if [value] is negative or |
| 96 * greater than 255. | 96 * greater than 255. |
| 97 */ | 97 */ |
| 98 int setUint8(int byteOffset, int value); | 98 int setUint8(int byteOffset, int value); |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Returns the (possibly negative) integer represented by the two bytes at | 101 * Returns the (possibly negative) integer represented by the two bytes at |
| 102 * the specified [byteOffset] in this byte array, in two's complement binary | 102 * the specified [byteOffset] in this byte array, in two's complement binary |
| 103 * form. The return value will be between 2<sup>15</sup> and 2<sup>15 - 1, | 103 * form. The return value will be between 2<sup>15</sup> and 2<sup>15 - 1, |
| 104 * inclusive. | 104 * inclusive. |
| 105 * | 105 * |
| 106 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 106 * Throws [RangeError] if [byteOffset] is negative, or |
| 107 * `byteOffset + 2` is greater than the length of this byte array. | 107 * `byteOffset + 2` is greater than the length of this byte array. |
| 108 */ | 108 */ |
| 109 int getInt16(int byteOffset); | 109 int getInt16(int byteOffset); |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Sets the two bytes starting at the specified [byteOffset] in this | 112 * Sets the two bytes starting at the specified [byteOffset] in this |
| 113 * byte array to the two's complement binary representation of the specified | 113 * byte array to the two's complement binary representation of the specified |
| 114 * [value], which must fit in two bytes. In other words, [value] must lie | 114 * [value], which must fit in two bytes. In other words, [value] must lie |
| 115 * between 2<sup>15</sup> and 2<sup>15 - 1, inclusive. | 115 * between 2<sup>15</sup> and 2<sup>15 - 1, inclusive. |
| 116 * | 116 * |
| 117 * Returns `byteOffset + 2`, which is the offset of the first byte in the | 117 * Returns `byteOffset + 2`, which is the offset of the first byte in the |
| 118 * array after the last byte that was set by this call. This return value can | 118 * array after the last byte that was set by this call. This return value can |
| 119 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 119 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 120 * | 120 * |
| 121 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 121 * Throws [RangeError] if [byteOffset] is negative, or |
| 122 * `byteOffset + 2` is greater than the length of this byte array. | 122 * `byteOffset + 2` is greater than the length of this byte array. |
| 123 * | 123 * |
| 124 * Throws [ArgumentError] if [value] is less than 2<sup>15</sup> | 124 * Throws [ArgumentError] if [value] is less than 2<sup>15</sup> |
| 125 * or greater than 2<sup>15 - 1. | 125 * or greater than 2<sup>15 - 1. |
| 126 */ | 126 */ |
| 127 int setInt16(int byteOffset, int value); | 127 int setInt16(int byteOffset, int value); |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * Returns the positive integer represented by the two bytes starting | 130 * Returns the positive integer represented by the two bytes starting |
| 131 * at the specified [byteOffset] in this byte array, in unsigned binary | 131 * at the specified [byteOffset] in this byte array, in unsigned binary |
| 132 * form. The return value will be between 0 and 2<sup>16 - 1, inclusive. | 132 * form. The return value will be between 0 and 2<sup>16 - 1, inclusive. |
| 133 * | 133 * |
| 134 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 134 * Throws [RangeError] if [byteOffset] is negative, or |
| 135 * `byteOffset + 2` is greater than the length of this byte array. | 135 * `byteOffset + 2` is greater than the length of this byte array. |
| 136 */ | 136 */ |
| 137 int getUint16(int byteOffset); | 137 int getUint16(int byteOffset); |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * Sets the two bytes starting at the specified [byteOffset] in this byte | 140 * Sets the two bytes starting at the specified [byteOffset] in this byte |
| 141 * array to the unsigned binary representation of the specified [value], | 141 * array to the unsigned binary representation of the specified [value], |
| 142 * which must fit in two bytes. in other words, [value] must be between | 142 * which must fit in two bytes. in other words, [value] must be between |
| 143 * 0 and 2<sup>16 - 1, inclusive. | 143 * 0 and 2<sup>16 - 1, inclusive. |
| 144 * | 144 * |
| 145 * Returns `byteOffset + 2`, which is the offset of the first byte in the | 145 * Returns `byteOffset + 2`, which is the offset of the first byte in the |
| 146 * array after the last byte that was set by this call. This return value can | 146 * array after the last byte that was set by this call. This return value can |
| 147 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 147 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 148 * | 148 * |
| 149 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 149 * Throws [RangeError] if [byteOffset] is negative, or |
| 150 * `byteOffset + 2` is greater than the length of this byte array. | 150 * `byteOffset + 2` is greater than the length of this byte array. |
| 151 * | 151 * |
| 152 * Throws [ArgumentError] if [value] is negative or | 152 * Throws [ArgumentError] if [value] is negative or |
| 153 * greater than 2<sup>16 - 1. | 153 * greater than 2<sup>16 - 1. |
| 154 */ | 154 */ |
| 155 int setUint16(int byteOffset, int value); | 155 int setUint16(int byteOffset, int value); |
| 156 | 156 |
| 157 /** | 157 /** |
| 158 * Returns the (possibly negative) integer represented by the four bytes at | 158 * Returns the (possibly negative) integer represented by the four bytes at |
| 159 * the specified [byteOffset] in this byte array, in two's complement binary | 159 * the specified [byteOffset] in this byte array, in two's complement binary |
| 160 * form. The return value will be between 2<sup>31</sup> and 2<sup>31 - 1, | 160 * form. The return value will be between 2<sup>31</sup> and 2<sup>31 - 1, |
| 161 * inclusive. | 161 * inclusive. |
| 162 * | 162 * |
| 163 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 163 * Throws [RangeError] if [byteOffset] is negative, or |
| 164 * `byteOffset + 4` is greater than the length of this byte array. | 164 * `byteOffset + 4` is greater than the length of this byte array. |
| 165 */ | 165 */ |
| 166 int getInt32(int byteOffset); | 166 int getInt32(int byteOffset); |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * Sets the four bytes starting at the specified [byteOffset] in this | 169 * Sets the four bytes starting at the specified [byteOffset] in this |
| 170 * byte array to the two's complement binary representation of the specified | 170 * byte array to the two's complement binary representation of the specified |
| 171 * [value], which must fit in four bytes. In other words, [value] must lie | 171 * [value], which must fit in four bytes. In other words, [value] must lie |
| 172 * between 2<sup>31</sup> and 2<sup>31 - 1, inclusive. | 172 * between 2<sup>31</sup> and 2<sup>31 - 1, inclusive. |
| 173 * | 173 * |
| 174 * Returns `byteOffset + 4`, which is the offset of the first byte in the | 174 * Returns `byteOffset + 4`, which is the offset of the first byte in the |
| 175 * array after the last byte that was set by this call. This return value can | 175 * array after the last byte that was set by this call. This return value can |
| 176 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 176 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 177 * | 177 * |
| 178 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 178 * Throws [RangeError] if [byteOffset] is negative, or |
| 179 * `byteOffset + 4` is greater than the length of this byte array. | 179 * `byteOffset + 4` is greater than the length of this byte array. |
| 180 * | 180 * |
| 181 * Throws [ArgumentError] if [value] is less than 2<sup>31</sup> | 181 * Throws [ArgumentError] if [value] is less than 2<sup>31</sup> |
| 182 * or greater than 2<sup>31 - 1. | 182 * or greater than 2<sup>31 - 1. |
| 183 */ | 183 */ |
| 184 int setInt32(int byteOffset, int value); | 184 int setInt32(int byteOffset, int value); |
| 185 | 185 |
| 186 /** | 186 /** |
| 187 * Returns the positive integer represented by the four bytes starting | 187 * Returns the positive integer represented by the four bytes starting |
| 188 * at the specified [byteOffset] in this byte array, in unsigned binary | 188 * at the specified [byteOffset] in this byte array, in unsigned binary |
| 189 * form. The return value will be between 0 and 2<sup>32 - 1, inclusive. | 189 * form. The return value will be between 0 and 2<sup>32 - 1, inclusive. |
| 190 * | 190 * |
| 191 */ | 191 */ |
| 192 int getUint32(int byteOffset); | 192 int getUint32(int byteOffset); |
| 193 | 193 |
| 194 /** | 194 /** |
| 195 * Sets the four bytes starting at the specified [byteOffset] in this byte | 195 * Sets the four bytes starting at the specified [byteOffset] in this byte |
| 196 * array to the unsigned binary representation of the specified [value], | 196 * array to the unsigned binary representation of the specified [value], |
| 197 * which must fit in four bytes. in other words, [value] must be between | 197 * which must fit in four bytes. in other words, [value] must be between |
| 198 * 0 and 2<sup>32 - 1, inclusive. | 198 * 0 and 2<sup>32 - 1, inclusive. |
| 199 * | 199 * |
| 200 * Returns `byteOffset + 4`, which is the offset of the first byte in the | 200 * Returns `byteOffset + 4`, which is the offset of the first byte in the |
| 201 * array after the last byte that was set by this call. This return value can | 201 * array after the last byte that was set by this call. This return value can |
| 202 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 202 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 203 * | 203 * |
| 204 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 204 * Throws [RangeError] if [byteOffset] is negative, or |
| 205 * `byteOffset + 4` is greater than the length of this byte array. | 205 * `byteOffset + 4` is greater than the length of this byte array. |
| 206 * | 206 * |
| 207 * Throws [ArgumentError] if [value] is negative or | 207 * Throws [ArgumentError] if [value] is negative or |
| 208 * greater than 2<sup>32 - 1. | 208 * greater than 2<sup>32 - 1. |
| 209 */ | 209 */ |
| 210 int setUint32(int byteOffset, int value); | 210 int setUint32(int byteOffset, int value); |
| 211 | 211 |
| 212 /** | 212 /** |
| 213 * Returns the (possibly negative) integer represented by the eight bytes at | 213 * Returns the (possibly negative) integer represented by the eight bytes at |
| 214 * the specified [byteOffset] in this byte array, in two's complement binary | 214 * the specified [byteOffset] in this byte array, in two's complement binary |
| 215 * form. The return value will be between 2<sup>63</sup> and 2<sup>63 - 1, | 215 * form. The return value will be between 2<sup>63</sup> and 2<sup>63 - 1, |
| 216 * inclusive. | 216 * inclusive. |
| 217 * | 217 * |
| 218 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 218 * Throws [RangeError] if [byteOffset] is negative, or |
| 219 * `byteOffset + 8` is greater than the length of this byte array. | 219 * `byteOffset + 8` is greater than the length of this byte array. |
| 220 */ | 220 */ |
| 221 int getInt64(int byteOffset); | 221 int getInt64(int byteOffset); |
| 222 | 222 |
| 223 /** | 223 /** |
| 224 * Sets the eight bytes starting at the specified [byteOffset] in this | 224 * Sets the eight bytes starting at the specified [byteOffset] in this |
| 225 * byte array to the two's complement binary representation of the specified | 225 * byte array to the two's complement binary representation of the specified |
| 226 * [value], which must fit in eight bytes. In other words, [value] must lie | 226 * [value], which must fit in eight bytes. In other words, [value] must lie |
| 227 * between 2<sup>63</sup> and 2<sup>63 - 1, inclusive. | 227 * between 2<sup>63</sup> and 2<sup>63 - 1, inclusive. |
| 228 * | 228 * |
| 229 * Returns `byteOffset + 8`, which is the offset of the first byte in the | 229 * Returns `byteOffset + 8`, which is the offset of the first byte in the |
| 230 * array after the last byte that was set by this call. This return value can | 230 * array after the last byte that was set by this call. This return value can |
| 231 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 231 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 232 * | 232 * |
| 233 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 233 * Throws [RangeError] if [byteOffset] is negative, or |
| 234 * `byteOffset + 8` is greater than the length of this byte array. | 234 * `byteOffset + 8` is greater than the length of this byte array. |
| 235 * | 235 * |
| 236 * Throws [ArgumentError] if [value] is less than 2<sup>63</sup> | 236 * Throws [ArgumentError] if [value] is less than 2<sup>63</sup> |
| 237 * or greater than 2<sup>63 - 1. | 237 * or greater than 2<sup>63 - 1. |
| 238 */ | 238 */ |
| 239 int setInt64(int byteOffset, int value); | 239 int setInt64(int byteOffset, int value); |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * Returns the positive integer represented by the eight bytes starting | 242 * Returns the positive integer represented by the eight bytes starting |
| 243 * at the specified [byteOffset] in this byte array, in unsigned binary | 243 * at the specified [byteOffset] in this byte array, in unsigned binary |
| 244 * form. The return value will be between 0 and 2<sup>64 - 1, inclusive. | 244 * form. The return value will be between 0 and 2<sup>64 - 1, inclusive. |
| 245 * | 245 * |
| 246 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 246 * Throws [RangeError] if [byteOffset] is negative, or |
| 247 * `byteOffset + 8` is greater than the length of this byte array. | 247 * `byteOffset + 8` is greater than the length of this byte array. |
| 248 */ | 248 */ |
| 249 int getUint64(int byteOffset); | 249 int getUint64(int byteOffset); |
| 250 | 250 |
| 251 /** | 251 /** |
| 252 * Sets the eight bytes starting at the specified [byteOffset] in this byte | 252 * Sets the eight bytes starting at the specified [byteOffset] in this byte |
| 253 * array to the unsigned binary representation of the specified [value], | 253 * array to the unsigned binary representation of the specified [value], |
| 254 * which must fit in eight bytes. in other words, [value] must be between | 254 * which must fit in eight bytes. in other words, [value] must be between |
| 255 * 0 and 2<sup>64 - 1, inclusive. | 255 * 0 and 2<sup>64 - 1, inclusive. |
| 256 * | 256 * |
| 257 * Returns `byteOffset + 8`, which is the offset of the first byte in the | 257 * Returns `byteOffset + 8`, which is the offset of the first byte in the |
| 258 * array after the last byte that was set by this call. This return value can | 258 * array after the last byte that was set by this call. This return value can |
| 259 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 259 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 260 * | 260 * |
| 261 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 261 * Throws [RangeError] if [byteOffset] is negative, or |
| 262 * `byteOffset + 8` is greater than the length of this byte array. | 262 * `byteOffset + 8` is greater than the length of this byte array. |
| 263 * | 263 * |
| 264 * Throws [ArgumentError] if [value] is negative or | 264 * Throws [ArgumentError] if [value] is negative or |
| 265 * greater than 2<sup>64 - 1. | 265 * greater than 2<sup>64 - 1. |
| 266 */ | 266 */ |
| 267 int setUint64(int byteOffset, int value); | 267 int setUint64(int byteOffset, int value); |
| 268 | 268 |
| 269 /** | 269 /** |
| 270 * Returns the floating point number represented by the four bytes at | 270 * Returns the floating point number represented by the four bytes at |
| 271 * the specified [byteOffset] in this byte array, in IEEE 754 | 271 * the specified [byteOffset] in this byte array, in IEEE 754 |
| 272 * single-precision binary floating-point format (binary32). | 272 * single-precision binary floating-point format (binary32). |
| 273 * | 273 * |
| 274 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 274 * Throws [RangeError] if [byteOffset] is negative, or |
| 275 * `byteOffset + 4` is greater than the length of this byte array. | 275 * `byteOffset + 4` is greater than the length of this byte array. |
| 276 */ | 276 */ |
| 277 double getFloat32(int byteOffset); | 277 double getFloat32(int byteOffset); |
| 278 | 278 |
| 279 /** | 279 /** |
| 280 * Sets the four bytes starting at the specified [byteOffset] in this | 280 * Sets the four bytes starting at the specified [byteOffset] in this |
| 281 * byte array to the IEEE 754 single-precision binary floating-point | 281 * byte array to the IEEE 754 single-precision binary floating-point |
| 282 * (binary32) representation of the specified [value]. | 282 * (binary32) representation of the specified [value]. |
| 283 * | 283 * |
| 284 * **Note that this method can lose precision.** The input [value] is | 284 * **Note that this method can lose precision.** The input [value] is |
| 285 * a 64-bit floating point value, which will be converted to 32-bit | 285 * a 64-bit floating point value, which will be converted to 32-bit |
| 286 * floating point value by IEEE 754 rounding rules before it is stored. | 286 * floating point value by IEEE 754 rounding rules before it is stored. |
| 287 * If [value] cannot be represented exactly as a binary32, it will be | 287 * If [value] cannot be represented exactly as a binary32, it will be |
| 288 * converted to the nearest binary32 value. If two binary32 values are | 288 * converted to the nearest binary32 value. If two binary32 values are |
| 289 * equally close, the one whose least significant bit is zero will be used. | 289 * equally close, the one whose least significant bit is zero will be used. |
| 290 * Note that finite (but large) values can be converted to infinity, and | 290 * Note that finite (but large) values can be converted to infinity, and |
| 291 * small non-zero values can be converted to zero. | 291 * small non-zero values can be converted to zero. |
| 292 * | 292 * |
| 293 * Returns `byteOffset + 4`, which is the offset of the first byte in the | 293 * Returns `byteOffset + 4`, which is the offset of the first byte in the |
| 294 * array after the last byte that was set by this call. This return value can | 294 * array after the last byte that was set by this call. This return value can |
| 295 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 295 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 296 * | 296 * |
| 297 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 297 * Throws [RangeError] if [byteOffset] is negative, or |
| 298 * `byteOffset + 4` is greater than the length of this byte array. | 298 * `byteOffset + 4` is greater than the length of this byte array. |
| 299 */ | 299 */ |
| 300 int setFloat32(int byteOffset, double value); | 300 int setFloat32(int byteOffset, double value); |
| 301 | 301 |
| 302 /** | 302 /** |
| 303 * Returns the floating point number represented by the eight bytes at | 303 * Returns the floating point number represented by the eight bytes at |
| 304 * the specified [byteOffset] in this byte array, in IEEE 754 | 304 * the specified [byteOffset] in this byte array, in IEEE 754 |
| 305 * double-precision binary floating-point format (binary64). | 305 * double-precision binary floating-point format (binary64). |
| 306 * | 306 * |
| 307 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 307 * Throws [RangeError] if [byteOffset] is negative, or |
| 308 * `byteOffset + 8` is greater than the length of this byte array. | 308 * `byteOffset + 8` is greater than the length of this byte array. |
| 309 */ | 309 */ |
| 310 double getFloat64(int byteOffset); | 310 double getFloat64(int byteOffset); |
| 311 | 311 |
| 312 /** | 312 /** |
| 313 * Sets the eight bytes starting at the specified [byteOffset] in this | 313 * Sets the eight bytes starting at the specified [byteOffset] in this |
| 314 * byte array to the IEEE 754 double-precision binary floating-point | 314 * byte array to the IEEE 754 double-precision binary floating-point |
| 315 * (binary64) representation of the specified [value]. | 315 * (binary64) representation of the specified [value]. |
| 316 * | 316 * |
| 317 * Returns `byteOffset + 8`, which is the offset of the first byte in the | 317 * Returns `byteOffset + 8`, which is the offset of the first byte in the |
| 318 * array after the last byte that was set by this call. This return value can | 318 * array after the last byte that was set by this call. This return value can |
| 319 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | 319 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. |
| 320 * | 320 * |
| 321 * Throws [IndexOutOfRangeException] if [byteOffset] is negative, or | 321 * Throws [RangeError] if [byteOffset] is negative, or |
| 322 * `byteOffset + 8` is greater than the length of this byte array. | 322 * `byteOffset + 8` is greater than the length of this byte array. |
| 323 */ | 323 */ |
| 324 int setFloat64(int byteOffset, double value); | 324 int setFloat64(int byteOffset, double value); |
| 325 } | 325 } |
| 326 | 326 |
| 327 /** | 327 /** |
| 328 * A "mixin interface" that allows a type, typically but not necessarily | 328 * A "mixin interface" that allows a type, typically but not necessarily |
| 329 * a [List], to be viewed as a [ByteArray]. | 329 * a [List], to be viewed as a [ByteArray]. |
| 330 */ | 330 */ |
| 331 abstract class ByteArrayViewable { | 331 abstract class ByteArrayViewable { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 * [start] of the region is not divisible by 8. If, however, [array] | 662 * [start] of the region is not divisible by 8. If, however, [array] |
| 663 * is a view of another byte array, this constructor will throw | 663 * is a view of another byte array, this constructor will throw |
| 664 * [ArgumentError] if the implicit starting position in the | 664 * [ArgumentError] if the implicit starting position in the |
| 665 * "ultimately backing" byte array is not divisible by 8. In plain terms, | 665 * "ultimately backing" byte array is not divisible by 8. In plain terms, |
| 666 * this constructor throws [ArgumentError] if the specified | 666 * this constructor throws [ArgumentError] if the specified |
| 667 * region does not contain an integral number of "float64s," or if it | 667 * region does not contain an integral number of "float64s," or if it |
| 668 * is not "float64-aligned." | 668 * is not "float64-aligned." |
| 669 */ | 669 */ |
| 670 external factory Float64List.view(ByteArray array, [int start, int length]); | 670 external factory Float64List.view(ByteArray array, [int start, int length]); |
| 671 } | 671 } |
| OLD | NEW |