@@ -1201,30 +1201,7 @@ impl<'a> ConstantEvaluator<'a> {
12011201 component_wise_float ! ( self , span, [ arg] , |e| { Ok ( [ e. floor( ) ] ) } )
12021202 }
12031203 crate :: MathFunction :: Round => {
1204- // TODO: this hit stable on 1.77, but MSRV hasn't caught up yet
1205- // This polyfill is shamelessly [~~stolen from~~ inspired by `ndarray-image`][polyfill source],
1206- // which has licensing compatible with ours. See also
1207- // <https://github.com/rust-lang/rust/issues/96710>.
1208- //
1209- // [polyfill source]: https://github.com/imeka/ndarray-ndimage/blob/8b14b4d6ecfbc96a8a052f802e342a7049c68d8f/src/lib.rs#L98
1210- fn round_ties_even ( x : f64 ) -> f64 {
1211- let i = x as i64 ;
1212- let f = ( x - i as f64 ) . abs ( ) ;
1213- if f == 0.5 {
1214- if i & 1 == 1 {
1215- // -1.5, 1.5, 3.5, ...
1216- ( x. abs ( ) + 0.5 ) . copysign ( x)
1217- } else {
1218- ( x. abs ( ) - 0.5 ) . copysign ( x)
1219- }
1220- } else {
1221- x. round ( )
1222- }
1223- }
1224- component_wise_float ( self , span, [ arg] , |e| match e {
1225- Float :: Abstract ( [ e] ) => Ok ( Float :: Abstract ( [ round_ties_even ( e) ] ) ) ,
1226- Float :: F32 ( [ e] ) => Ok ( Float :: F32 ( [ ( round_ties_even ( e as f64 ) as f32 ) ] ) ) ,
1227- } )
1204+ component_wise_float ! ( self , span, [ arg] , |e| { Ok ( [ e. round_ties_even( ) ] ) } )
12281205 }
12291206 crate :: MathFunction :: Fract => {
12301207 component_wise_float ! ( self , span, [ arg] , |e| {
0 commit comments