Hi,
May I know that how to format a float number with specific number of
decimal point, please?
e.g :–
123.456789 to 123.4568
123.123321 to 123.1233
Thanks
Regards
Oscar
Hi,
May I know that how to format a float number with specific number of
decimal point, please?
e.g :–
123.456789 to 123.4568
123.123321 to 123.1233
Thanks
Regards
Oscar
Oscar L. [email protected] writes:
Hi,
May I know that how to format a float number with specific number of
decimal point, please?
e.g :–
123.456789 to 123.4568
123.123321 to 123.1233
irb(main):039:0> print [123.456789, 123.123321].collect {|x|
format(“#{x} to %.4f\n”,x)}
123.456789 to 123.4568
123.123321 to 123.1233
=> nil
irb(main):040:0>
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs