@@ -818,6 +818,23 @@ impl FloatCore for f32 {
818818 Self :: to_degrees( self ) -> Self ;
819819 Self :: to_radians( self ) -> Self ;
820820 }
821+
822+ #[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
823+ forward ! {
824+ libm:: floorf as floor( self ) -> Self ;
825+ libm:: ceilf as ceil( self ) -> Self ;
826+ libm:: roundf as round( self ) -> Self ;
827+ libm:: truncf as trunc( self ) -> Self ;
828+ libm:: fabsf as abs( self ) -> Self ;
829+ libm:: fminf as min( self , other: Self ) -> Self ;
830+ libm:: fmaxf as max( self , other: Self ) -> Self ;
831+ }
832+
833+ #[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
834+ #[ inline]
835+ fn fract ( self ) -> Self {
836+ self - libm:: truncf ( self )
837+ }
821838}
822839
823840impl FloatCore for f64 {
@@ -893,6 +910,23 @@ impl FloatCore for f64 {
893910 Self :: to_degrees( self ) -> Self ;
894911 Self :: to_radians( self ) -> Self ;
895912 }
913+
914+ #[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
915+ forward ! {
916+ libm:: floor as floor( self ) -> Self ;
917+ libm:: ceil as ceil( self ) -> Self ;
918+ libm:: round as round( self ) -> Self ;
919+ libm:: trunc as trunc( self ) -> Self ;
920+ libm:: fabs as abs( self ) -> Self ;
921+ libm:: fmin as min( self , other: Self ) -> Self ;
922+ libm:: fmax as max( self , other: Self ) -> Self ;
923+ }
924+
925+ #[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
926+ #[ inline]
927+ fn fract ( self ) -> Self {
928+ self - libm:: trunc ( self )
929+ }
896930}
897931
898932// FIXME: these doctests aren't actually helpful, because they're using and
@@ -1908,7 +1942,7 @@ macro_rules! float_impl_libm {
19081942
19091943 #[ inline]
19101944 fn fract( self ) -> Self {
1911- self - FloatCore :: trunc( self )
1945+ self - Float :: trunc( self )
19121946 }
19131947
19141948 #[ inline]
@@ -1929,8 +1963,6 @@ macro_rules! float_impl_libm {
19291963 FloatCore :: powi( self , n: i32 ) -> Self ;
19301964 FloatCore :: to_degrees( self ) -> Self ;
19311965 FloatCore :: to_radians( self ) -> Self ;
1932- FloatCore :: max( self , other: Self ) -> Self ;
1933- FloatCore :: min( self , other: Self ) -> Self ;
19341966 }
19351967 } ;
19361968}
@@ -1981,129 +2013,41 @@ impl Float for f32 {
19812013 fn abs_sub ( self , other : Self ) -> Self {
19822014 libm:: fdimf ( self , other)
19832015 }
1984- #[ inline]
1985- fn floor ( self ) -> Self {
1986- libm:: floorf ( self )
1987- }
1988- #[ inline]
1989- fn ceil ( self ) -> Self {
1990- libm:: ceilf ( self )
1991- }
1992- #[ inline]
1993- fn round ( self ) -> Self {
1994- libm:: roundf ( self )
1995- }
1996- #[ inline]
1997- fn trunc ( self ) -> Self {
1998- libm:: truncf ( self )
1999- }
2000- #[ inline]
2001- fn abs ( self ) -> Self {
2002- libm:: fabsf ( self )
2003- }
2004- #[ inline]
2005- fn mul_add ( self , a : Self , b : Self ) -> Self {
2006- libm:: fmaf ( self , a, b)
2007- }
2008- #[ inline]
2009- fn powf ( self , n : Self ) -> Self {
2010- libm:: powf ( self , n)
2011- }
2012- #[ inline]
2013- fn sqrt ( self ) -> Self {
2014- libm:: sqrtf ( self )
2015- }
2016- #[ inline]
2017- fn exp ( self ) -> Self {
2018- libm:: expf ( self )
2019- }
2020- #[ inline]
2021- fn exp2 ( self ) -> Self {
2022- libm:: exp2f ( self )
2023- }
2024- #[ inline]
2025- fn ln ( self ) -> Self {
2026- libm:: logf ( self )
2027- }
2028- #[ inline]
2029- fn log2 ( self ) -> Self {
2030- libm:: log2f ( self )
2031- }
2032- #[ inline]
2033- fn log10 ( self ) -> Self {
2034- libm:: log10f ( self )
2035- }
2036- #[ inline]
2037- fn cbrt ( self ) -> Self {
2038- libm:: cbrtf ( self )
2039- }
2040- #[ inline]
2041- fn hypot ( self , other : Self ) -> Self {
2042- libm:: hypotf ( self , other)
2043- }
2044- #[ inline]
2045- fn sin ( self ) -> Self {
2046- libm:: sinf ( self )
2047- }
2048- #[ inline]
2049- fn cos ( self ) -> Self {
2050- libm:: cosf ( self )
2051- }
2052- #[ inline]
2053- fn tan ( self ) -> Self {
2054- libm:: tanf ( self )
2055- }
2056- #[ inline]
2057- fn asin ( self ) -> Self {
2058- libm:: asinf ( self )
2059- }
2060- #[ inline]
2061- fn acos ( self ) -> Self {
2062- libm:: acosf ( self )
2063- }
2064- #[ inline]
2065- fn atan ( self ) -> Self {
2066- libm:: atanf ( self )
2067- }
2068- #[ inline]
2069- fn atan2 ( self , other : Self ) -> Self {
2070- libm:: atan2f ( self , other)
2071- }
2072- #[ inline]
2073- fn sin_cos ( self ) -> ( Self , Self ) {
2074- libm:: sincosf ( self )
2075- }
2076- #[ inline]
2077- fn exp_m1 ( self ) -> Self {
2078- libm:: expm1f ( self )
2079- }
2080- #[ inline]
2081- fn ln_1p ( self ) -> Self {
2082- libm:: log1pf ( self )
2083- }
2084- #[ inline]
2085- fn sinh ( self ) -> Self {
2086- libm:: sinhf ( self )
2087- }
2088- #[ inline]
2089- fn cosh ( self ) -> Self {
2090- libm:: coshf ( self )
2091- }
2092- #[ inline]
2093- fn tanh ( self ) -> Self {
2094- libm:: tanhf ( self )
2095- }
2096- #[ inline]
2097- fn asinh ( self ) -> Self {
2098- libm:: asinhf ( self )
2099- }
2100- #[ inline]
2101- fn acosh ( self ) -> Self {
2102- libm:: acoshf ( self )
2103- }
2104- #[ inline]
2105- fn atanh ( self ) -> Self {
2106- libm:: atanhf ( self )
2016+
2017+ forward ! {
2018+ libm:: floorf as floor( self ) -> Self ;
2019+ libm:: ceilf as ceil( self ) -> Self ;
2020+ libm:: roundf as round( self ) -> Self ;
2021+ libm:: truncf as trunc( self ) -> Self ;
2022+ libm:: fabsf as abs( self ) -> Self ;
2023+ libm:: fmaf as mul_add( self , a: Self , b: Self ) -> Self ;
2024+ libm:: powf as powf( self , n: Self ) -> Self ;
2025+ libm:: sqrtf as sqrt( self ) -> Self ;
2026+ libm:: expf as exp( self ) -> Self ;
2027+ libm:: exp2f as exp2( self ) -> Self ;
2028+ libm:: logf as ln( self ) -> Self ;
2029+ libm:: log2f as log2( self ) -> Self ;
2030+ libm:: log10f as log10( self ) -> Self ;
2031+ libm:: cbrtf as cbrt( self ) -> Self ;
2032+ libm:: hypotf as hypot( self , other: Self ) -> Self ;
2033+ libm:: sinf as sin( self ) -> Self ;
2034+ libm:: cosf as cos( self ) -> Self ;
2035+ libm:: tanf as tan( self ) -> Self ;
2036+ libm:: asinf as asin( self ) -> Self ;
2037+ libm:: acosf as acos( self ) -> Self ;
2038+ libm:: atanf as atan( self ) -> Self ;
2039+ libm:: atan2f as atan2( self , other: Self ) -> Self ;
2040+ libm:: sincosf as sin_cos( self ) -> ( Self , Self ) ;
2041+ libm:: expm1f as exp_m1( self ) -> Self ;
2042+ libm:: log1pf as ln_1p( self ) -> Self ;
2043+ libm:: sinhf as sinh( self ) -> Self ;
2044+ libm:: coshf as cosh( self ) -> Self ;
2045+ libm:: tanhf as tanh( self ) -> Self ;
2046+ libm:: asinhf as asinh( self ) -> Self ;
2047+ libm:: acoshf as acosh( self ) -> Self ;
2048+ libm:: atanhf as atanh( self ) -> Self ;
2049+ libm:: fmaxf as max( self , other: Self ) -> Self ;
2050+ libm:: fminf as min( self , other: Self ) -> Self ;
21072051 }
21082052}
21092053
@@ -2116,129 +2060,41 @@ impl Float for f64 {
21162060 fn abs_sub ( self , other : Self ) -> Self {
21172061 libm:: fdim ( self , other)
21182062 }
2119- #[ inline]
2120- fn floor ( self ) -> Self {
2121- libm:: floor ( self )
2122- }
2123- #[ inline]
2124- fn ceil ( self ) -> Self {
2125- libm:: ceil ( self )
2126- }
2127- #[ inline]
2128- fn round ( self ) -> Self {
2129- libm:: round ( self )
2130- }
2131- #[ inline]
2132- fn trunc ( self ) -> Self {
2133- libm:: trunc ( self )
2134- }
2135- #[ inline]
2136- fn abs ( self ) -> Self {
2137- libm:: fabs ( self )
2138- }
2139- #[ inline]
2140- fn mul_add ( self , a : Self , b : Self ) -> Self {
2141- libm:: fma ( self , a, b)
2142- }
2143- #[ inline]
2144- fn powf ( self , n : Self ) -> Self {
2145- libm:: pow ( self , n)
2146- }
2147- #[ inline]
2148- fn sqrt ( self ) -> Self {
2149- libm:: sqrt ( self )
2150- }
2151- #[ inline]
2152- fn exp ( self ) -> Self {
2153- libm:: exp ( self )
2154- }
2155- #[ inline]
2156- fn exp2 ( self ) -> Self {
2157- libm:: exp2 ( self )
2158- }
2159- #[ inline]
2160- fn ln ( self ) -> Self {
2161- libm:: log ( self )
2162- }
2163- #[ inline]
2164- fn log2 ( self ) -> Self {
2165- libm:: log2 ( self )
2166- }
2167- #[ inline]
2168- fn log10 ( self ) -> Self {
2169- libm:: log10 ( self )
2170- }
2171- #[ inline]
2172- fn cbrt ( self ) -> Self {
2173- libm:: cbrt ( self )
2174- }
2175- #[ inline]
2176- fn hypot ( self , other : Self ) -> Self {
2177- libm:: hypot ( self , other)
2178- }
2179- #[ inline]
2180- fn sin ( self ) -> Self {
2181- libm:: sin ( self )
2182- }
2183- #[ inline]
2184- fn cos ( self ) -> Self {
2185- libm:: cos ( self )
2186- }
2187- #[ inline]
2188- fn tan ( self ) -> Self {
2189- libm:: tan ( self )
2190- }
2191- #[ inline]
2192- fn asin ( self ) -> Self {
2193- libm:: asin ( self )
2194- }
2195- #[ inline]
2196- fn acos ( self ) -> Self {
2197- libm:: acos ( self )
2198- }
2199- #[ inline]
2200- fn atan ( self ) -> Self {
2201- libm:: atan ( self )
2202- }
2203- #[ inline]
2204- fn atan2 ( self , other : Self ) -> Self {
2205- libm:: atan2 ( self , other)
2206- }
2207- #[ inline]
2208- fn sin_cos ( self ) -> ( Self , Self ) {
2209- libm:: sincos ( self )
2210- }
2211- #[ inline]
2212- fn exp_m1 ( self ) -> Self {
2213- libm:: expm1 ( self )
2214- }
2215- #[ inline]
2216- fn ln_1p ( self ) -> Self {
2217- libm:: log1p ( self )
2218- }
2219- #[ inline]
2220- fn sinh ( self ) -> Self {
2221- libm:: sinh ( self )
2222- }
2223- #[ inline]
2224- fn cosh ( self ) -> Self {
2225- libm:: cosh ( self )
2226- }
2227- #[ inline]
2228- fn tanh ( self ) -> Self {
2229- libm:: tanh ( self )
2230- }
2231- #[ inline]
2232- fn asinh ( self ) -> Self {
2233- libm:: asinh ( self )
2234- }
2235- #[ inline]
2236- fn acosh ( self ) -> Self {
2237- libm:: acosh ( self )
2238- }
2239- #[ inline]
2240- fn atanh ( self ) -> Self {
2241- libm:: atanh ( self )
2063+
2064+ forward ! {
2065+ libm:: floor as floor( self ) -> Self ;
2066+ libm:: ceil as ceil( self ) -> Self ;
2067+ libm:: round as round( self ) -> Self ;
2068+ libm:: trunc as trunc( self ) -> Self ;
2069+ libm:: fabs as abs( self ) -> Self ;
2070+ libm:: fma as mul_add( self , a: Self , b: Self ) -> Self ;
2071+ libm:: pow as powf( self , n: Self ) -> Self ;
2072+ libm:: sqrt as sqrt( self ) -> Self ;
2073+ libm:: exp as exp( self ) -> Self ;
2074+ libm:: exp2 as exp2( self ) -> Self ;
2075+ libm:: log as ln( self ) -> Self ;
2076+ libm:: log2 as log2( self ) -> Self ;
2077+ libm:: log10 as log10( self ) -> Self ;
2078+ libm:: cbrt as cbrt( self ) -> Self ;
2079+ libm:: hypot as hypot( self , other: Self ) -> Self ;
2080+ libm:: sin as sin( self ) -> Self ;
2081+ libm:: cos as cos( self ) -> Self ;
2082+ libm:: tan as tan( self ) -> Self ;
2083+ libm:: asin as asin( self ) -> Self ;
2084+ libm:: acos as acos( self ) -> Self ;
2085+ libm:: atan as atan( self ) -> Self ;
2086+ libm:: atan2 as atan2( self , other: Self ) -> Self ;
2087+ libm:: sincos as sin_cos( self ) -> ( Self , Self ) ;
2088+ libm:: expm1 as exp_m1( self ) -> Self ;
2089+ libm:: log1p as ln_1p( self ) -> Self ;
2090+ libm:: sinh as sinh( self ) -> Self ;
2091+ libm:: cosh as cosh( self ) -> Self ;
2092+ libm:: tanh as tanh( self ) -> Self ;
2093+ libm:: asinh as asinh( self ) -> Self ;
2094+ libm:: acosh as acosh( self ) -> Self ;
2095+ libm:: atanh as atanh( self ) -> Self ;
2096+ libm:: fmax as max( self , other: Self ) -> Self ;
2097+ libm:: fmin as min( self , other: Self ) -> Self ;
22422098 }
22432099}
22442100
0 commit comments