Discussion
Loading...

#Tag

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
alexanderadam
alexanderadam
@alexanderadam@ruby.social  ·  activity timestamp 2 months ago

ruby #Ruby's #Float contains interesting constants.

Like EPSILON, which is the

> difference between 1 and the smallest double-precision floating point number greater than 1.

What is it useful for, you ask?
Well, Floats are kinda difficult for computers and if you want to compare them for equality without using `round` or alike, you can check whether its difference is within EPSILON range.

So it is kinda close to how Math uses it (ε).

https://ruby-doc.org/3.4.1/Float.html#5Buntitled-5D

#RubyLang #RubyProgramming

class Float - RDoc Documentation

  • Copy link
  • Flag this post
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-alpha.14 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login