comparison liboctave/idx-vector.cc @ 9007:7e31df9a0334

simplify double->int conversion in indexing
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 23 Mar 2009 14:23:48 +0100
parents 5fa53d1b6247
children ac0a23e9f5c5
comparison
equal deleted inserted replaced
9006:979d0492ff40 9007:7e31df9a0334
180 } 180 }
181 181
182 inline octave_idx_type 182 inline octave_idx_type
183 convert_index (double x, bool& conv_error, octave_idx_type& ext) 183 convert_index (double x, bool& conv_error, octave_idx_type& ext)
184 { 184 {
185 octave_idx_type i; 185 octave_idx_type i = static_cast<octave_idx_type> (x);
186 if (xisnan (x) || xisinf (x)) 186 if (static_cast<double> (i) != x)
187 { 187 conv_error = true;
188 i = 0;
189 conv_error = true;
190 }
191 else
192 {
193 i = static_cast<octave_idx_type> (x);
194 if (static_cast<double> (i) != x)
195 conv_error = true;
196 }
197 188
198 return convert_index (i, conv_error, ext); 189 return convert_index (i, conv_error, ext);
199 } 190 }
200 191
201 inline octave_idx_type 192 inline octave_idx_type