Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
Ruby Numeric. Help - Sorry for bothering. RESOLVED
-
I have to display some values, and most of all are integers, but some will be float. This is why I must use float.
I want to get rid of zero to that values that don't require it.
This is what I want:%(#4000BF)[3.3 => 3.3
4.8 => 4.8]
16.0 => 16I could do the trick in many ways but I'm still looking for something native.
There is no native way, but I find this on web:
#extend the Float class class Float def to_i_if if self - floor == 0 floor else self end end endBut here will be a problem: if I have a number like this: 4.00001, won't be converted to integer. For that, the method to_i_if can be enhanced:
class Float def to_i_if(threshold=0) if self - floor <= threshold floor else self end end endtreshold => display format like this: 0.01 (how many zeroes you need)
I found this on web and I thought to share it.
Advertisement