Zulip Chat Archive
Stream: new members
Topic: Converting a native Float into a Rat?
Kevin Cheung (Jan 30 2024 at 14:09):
I would like to do something like the following to convert a native Lean 4 Float into a Rat:
def one_third_approx : Float := 0.3333
def one_third_approx_rat : ℚ := toRat one_third_approx
where toRat
is my wishful thinking. There is a FP.toRat
in mathlib4 but I didn't know how to make it work here. Is there a way to achieve such a conversion?
Ruben Van de Velde (Jan 30 2024 at 14:10):
Note that FP
is unrelated to built-in floats
Ruben Van de Velde (Jan 30 2024 at 14:12):
Loogle "Found 0 definitions mentioning Rat and Float. ", so I doubt it exists
Kevin Cheung (Jan 30 2024 at 15:17):
I see. So if one wants to create something like this, what would be the best route? Convert native Float to FP.Float first?
Last updated: May 02 2025 at 03:31 UTC