Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Side by Side Diff: sdk/lib/core/double.dart

Issue 12317107: ceil/floor/truncate/round return integers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload due to error3 Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/core/date_time.dart ('k') | sdk/lib/core/int.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of dart.core; 5 part of dart.core;
6 6
7 // TODO: Convert this abstract class into a concrete class double 7 // TODO: Convert this abstract class into a concrete class double
8 // that uses the patch class functionality to account for the 8 // that uses the patch class functionality to account for the
9 // different platform implementations. 9 // different platform implementations.
10 10
(...skipping 27 matching lines...) Expand all
38 /** Euclidean modulo operator. */ 38 /** Euclidean modulo operator. */
39 double operator %(num other); 39 double operator %(num other);
40 40
41 /** Division operator. */ 41 /** Division operator. */
42 double operator /(num other); 42 double operator /(num other);
43 43
44 /** 44 /**
45 * Truncating division operator. 45 * Truncating division operator.
46 * 46 *
47 * The result of the truncating division [:a ~/ b:] is equivalent to 47 * The result of the truncating division [:a ~/ b:] is equivalent to
48 * [:(a / b).truncate().toInt():]. 48 * [:(a / b).truncate():].
49 */ 49 */
50 int operator ~/(num other); 50 int operator ~/(num other);
51 51
52 /** Negate operator. */ 52 /** Negate operator. */
53 double operator -(); 53 double operator -();
54 54
55 /** Returns the absolute value of this [double]. */ 55 /** Returns the absolute value of this [double]. */
56 double abs(); 56 double abs();
57 57
58 /** 58 /**
59 * Returns the integer value closest to this [double]. 59 * Returns the integer closest to `this`.
60 *
61 * Rounds away from zero when there is no closest integer:
62 * [:(3.5).round() == 4:] and [:(-3.5).round() == -4:].
63 *
64 * If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError].
65 */
66 int round();
67
68 /**
69 * Returns the greatest integer no greater than `this`.
70 *
71 * If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError].
72 */
73 int floor();
74
75 /**
76 * Returns the least integer no smaller than `this`.
77 *
78 * If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError].
79 */
80 int ceil();
81
82 /**
83 * Returns the integer obtained by discarding any fractional
84 * digits from `this`.
85 *
86 * If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError].
87 */
88 int truncate();
89
90 /**
91 * Returns the integer value, as a double, closest to `this`.
60 * 92 *
61 * Rounds away from zero when there is no closest integer: 93 * Rounds away from zero when there is no closest integer:
62 * [:(3.5).round() == 4:] and [:(-3.5).round() == -4:]. 94 * [:(3.5).round() == 4:] and [:(-3.5).round() == -4:].
63 */ 95 */
64 double round(); 96 double roundToDouble();
65
66 /** Returns the greatest integer value no greater than this [double]. */
67 double floor();
68
69 /** Returns the least integer value that is no smaller than this [double]. */
70 double ceil();
71 97
72 /** 98 /**
73 * Returns the integer value obtained by discarding any fractional 99 * Returns the greatest integer value no greater than `this`.
74 * digits from this [double]. 100 *
101 * The result is a double.
75 */ 102 */
76 double truncate(); 103 double floorToDouble();
104
105 /**
106 * Returns the least integer value no smaller than `this`.
107 *
108 * The result is a double.
109 */
110 double ceilToDouble();
111
112 /**
113 * Returns the integer obtained by discarding any fractional
114 * digits from `this`.
115 *
116 * The result is a double.
117 */
118 double truncateToDouble();
77 119
78 /** 120 /**
79 * Provide a representation of this [double] value. 121 * Provide a representation of this [double] value.
80 * 122 *
81 * The representation is a number literal such that the closest double value 123 * The representation is a number literal such that the closest double value
82 * to the representation's mathematical value is this [double]. 124 * to the representation's mathematical value is this [double].
83 * 125 *
84 * Returns "NaN" for the Not-a-Number value. 126 * Returns "NaN" for the Not-a-Number value.
85 * Returns "Infinity" and "-Infinity" for positive and negative Infinity. 127 * Returns "Infinity" and "-Infinity" for positive and negative Infinity.
86 * Returns "-0.0" for negative zero. 128 * Returns "-0.0" for negative zero.
(...skipping 13 matching lines...) Expand all
100 * returns the corresponding double value. 142 * returns the corresponding double value.
101 * 143 *
102 * If the [soure] is not a valid double literal, the [handleError] 144 * If the [soure] is not a valid double literal, the [handleError]
103 * is called with the [source] as argument, and its return value is 145 * is called with the [source] as argument, and its return value is
104 * used instead. If no handleError is provided, a [FormatException] 146 * used instead. If no handleError is provided, a [FormatException]
105 * is thrown. 147 * is thrown.
106 */ 148 */
107 external static double parse(String source, 149 external static double parse(String source,
108 [double handleError(String source)]); 150 [double handleError(String source)]);
109 } 151 }
OLDNEW
« no previous file with comments | « sdk/lib/core/date_time.dart ('k') | sdk/lib/core/int.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698