@@ -465,6 +465,37 @@ impl Float {
465465 } )
466466 }
467467
468+ /// Returns the zero value of a `Float` in its maximized representation.
469+ ///
470+ /// # Returns
471+ ///
472+ /// * `Ok(Float)` - The zero value.
473+ /// * `Err(FloatError)` - If the EVM call fails.
474+ ///
475+ /// # Example
476+ ///
477+ /// ```
478+ /// use rain_math_float::Float;
479+ ///
480+ /// let zero = Float::zero()?;
481+ /// assert!(zero.is_zero()?);
482+ /// assert_eq!(zero.format()?, "0");
483+ ///
484+ /// // Should be equal to parsed zero
485+ /// let parsed_zero = Float::parse("0".to_string())?;
486+ /// assert!(zero.eq(parsed_zero)?);
487+ ///
488+ /// anyhow::Ok(())
489+ /// ```
490+ pub fn zero ( ) -> Result < Self , FloatError > {
491+ let calldata = DecimalFloat :: zeroCall { } . abi_encode ( ) ;
492+
493+ execute_call ( Bytes :: from ( calldata) , |output| {
494+ let decoded = DecimalFloat :: zeroCall:: abi_decode_returns ( output. as_ref ( ) ) ?;
495+ Ok ( Float ( decoded) )
496+ } )
497+ }
498+
468499 /// Formats the float as a decimal string with a default significant figures limit of 18.
469500 ///
470501 /// # Returns
@@ -1099,6 +1130,20 @@ mod tests {
10991130 assert ! ( zero. eq( Float :: default ( ) ) . unwrap( ) ) ;
11001131 }
11011132
1133+ #[ test]
1134+ fn test_zero ( ) {
1135+ let zero = Float :: zero ( ) . unwrap ( ) ;
1136+ assert ! ( zero. is_zero( ) . unwrap( ) ) ;
1137+ assert_eq ! ( zero. format( ) . unwrap( ) , "0" ) ;
1138+
1139+ // Test that zero equals parsed zero
1140+ let parsed_zero = Float :: parse ( "0" . to_string ( ) ) . unwrap ( ) ;
1141+ assert ! ( zero. eq( parsed_zero) . unwrap( ) ) ;
1142+
1143+ // Test that zero equals default
1144+ assert ! ( zero. eq( Float :: default ( ) ) . unwrap( ) ) ;
1145+ }
1146+
11021147 prop_compose ! {
11031148 fn arb_float( ) (
11041149 coefficient in any:: <I224 >( ) ,
0 commit comments