Skip to content

Commit 105925a

Browse files
Comment corrections in string_constraint_generator_float
1 parent a8b1e8e commit 105925a

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/solvers/refinement/string_constraint_generator_float.cpp

+16-11
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ Author: Romain Brenguier, [email protected]
2121
/// TODO: factorize with float_bv.cpp float_utils.h
2222
/// \param src: a floating point expression
2323
/// \param spec: specification for floating points
24-
/// \return A 32 bit integer representing the exponent. Note that 32 bits are
25-
/// sufficient for the exponent even in octuple precision.
24+
/// \return A new 32 bit integer expression representing the exponent.
25+
/// Note that 32 bits are sufficient for the exponent even
26+
/// in octuple precision.
2627
exprt get_exponent(
2728
const exprt &src, const ieee_float_spect &spec)
2829
{
2930
exprt exp_bits=extractbits_exprt(
3031
src, spec.f+spec.e-1, spec.f, unsignedbv_typet(spec.e));
3132

32-
// Exponent is in biased from (numbers form -128 to 127 are encoded with
33+
// Exponent is in biased from (numbers from -128 to 127 are encoded with
3334
// integer from 0 to 255) we have to remove the bias.
3435
return minus_exprt(
3536
typecast_exprt(exp_bits, signedbv_typet(32)),
@@ -45,7 +46,10 @@ exprt get_magnitude(const exprt &src, const ieee_float_spect &spec)
4546
return extractbits_exprt(src, spec.f-1, 0, unsignedbv_typet(spec.f));
4647
}
4748

48-
/// Gets the significand as a java integer, looking for the hidden bit
49+
/// Gets the significand as a java integer, looking for the hidden bit.
50+
/// Since the most significant bit is 1 for normalized number, it is not part
51+
/// of the encoding of the significand and is 0 only if all the bits of the
52+
/// exponent are 0, that is why it is called the hidden bit.
4953
/// \param src: a floating point expression
5054
/// \param spec: specification for floating points
5155
/// \param type: type of the output, should be unsigned with width greater than
@@ -65,6 +69,7 @@ exprt get_significand(
6569
return if_exprt(all_zeros, magnitude, with_hidden_bit);
6670
}
6771

72+
/// Create an expression to represent a float or double value.
6873
/// \param f: a floating point value in double precision
6974
/// \return an expression representing this floating point
7075
exprt constant_float(const double f, const ieee_float_spect &float_spec)
@@ -109,7 +114,7 @@ exprt floatbv_mult(const exprt &f, const exprt &g)
109114
/// other values that are in floating point representation.
110115
/// \param i: an expression representing an integer
111116
/// \param spec: specification for floating point numbers
112-
/// \return An expression representing representing the value of the input
117+
/// \return An expression representing the value of the input
113118
/// integer as a float.
114119
exprt floatbv_of_int_expr(const exprt &i, const ieee_float_spect &spec)
115120
{
@@ -119,14 +124,14 @@ exprt floatbv_of_int_expr(const exprt &i, const ieee_float_spect &spec)
119124

120125
/// Estimate the decimal exponent that should be used to represent a given
121126
/// floating point value in decimal.
122-
/// We are looking for d such that n * 10^d = m * 10^e, so:
127+
/// We are looking for d such that n * 10^d = m * 2^e, so:
123128
/// d = log_10(m) + log_10(2) * e - log_10(n)
124129
/// m -- the magnitude -- should be between 1 and 2 so log_10(m)
125130
/// in [0,log_10(2)].
126131
/// n -- the magnitude in base 10 -- should be between 1 and 10 so
127132
/// log_10(n) in [0, 1].
128133
/// So the estimate is given by:
129-
/// d ~=~ floor( log_10(2) * e)
134+
/// d ~=~ floor(log_10(2) * e)
130135
/// \param f: a floating point expression
131136
/// \param spec: specification for floating point
132137
exprt estimate_decimal_exponent(const exprt &f, const ieee_float_spect &spec)
@@ -136,13 +141,13 @@ exprt estimate_decimal_exponent(const exprt &f, const ieee_float_spect &spec)
136141
exprt float_bin_exp=floatbv_of_int_expr(bin_exp, spec);
137142
exprt dec_exp=floatbv_mult(float_bin_exp, log_10_of_2);
138143
binary_relation_exprt negative_exp(dec_exp, ID_lt, constant_float(0.0, spec));
139-
// Rounding to zero is not correct for negative number, so we remove 1.
144+
// Rounding to zero is not correct for negative numbers, so we substract 1.
140145
minus_exprt dec_minus_one(dec_exp, constant_float(1.0, spec));
141146
if_exprt adjust_for_neg(negative_exp, dec_minus_one, dec_exp);
142147
return round_expr_to_zero(adjust_for_neg);
143148
}
144149

145-
/// add axioms corresponding to the String.valueOf(F) java function
150+
/// Add axioms corresponding to the String.valueOf(F) java function
146151
/// \param f: function application with one float argument
147152
/// \return a new string expression
148153
string_exprt string_constraint_generatort::add_axioms_from_float(
@@ -152,7 +157,7 @@ string_exprt string_constraint_generatort::add_axioms_from_float(
152157
return add_axioms_from_float(args(f, 1)[0], ref_type);
153158
}
154159

155-
/// add axioms corresponding to the String.valueOf(D) java function
160+
/// Add axioms corresponding to the String.valueOf(D) java function
156161
/// \param f: function application with one double argument
157162
/// \return a new string expression
158163
string_exprt string_constraint_generatort::add_axioms_from_double(
@@ -162,7 +167,7 @@ string_exprt string_constraint_generatort::add_axioms_from_double(
162167
return add_axioms_from_float(args(f, 1)[0], ref_type);
163168
}
164169

165-
/// add axioms corresponding to the integer part of m, in decimal form with no
170+
/// Add axioms corresponding to the integer part of m, in decimal form with no
166171
/// leading zeroes, followed by '.' ('\u002E'), followed by one or more decimal
167172
/// digits representing the fractional part of m.
168173
///

0 commit comments

Comments
 (0)