P Pietro Pancino Member Licensed User Longtime User Dec 7, 2018 #1 Hi, I just need to get the fraction of a floating point number... for example: dim i as double = 1.25 log(rnd(i)) ---> display 1 how can I get the .25 ? I'm sure it's basic but I didn't found how to get it !
Hi, I just need to get the fraction of a floating point number... for example: dim i as double = 1.25 log(rnd(i)) ---> display 1 how can I get the .25 ? I'm sure it's basic but I didn't found how to get it !
klaus Expert Licensed User Longtime User Dec 7, 2018 #2 B4X: Private Frac as Double Frac = i - Floor(i) Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Dec 9, 2018 #4 Pietro Pancino said: Great, it's so obvious! Click to expand... Nothing is obvious... If you want to support negative numbers: B4X: Sub Frac (n As Double) As Double Dim i As Int = n Return Abs(n - i) End Sub Upvote 0
Pietro Pancino said: Great, it's so obvious! Click to expand... Nothing is obvious... If you want to support negative numbers: B4X: Sub Frac (n As Double) As Double Dim i As Int = n Return Abs(n - i) End Sub