Italian Come conoscere se un numero è frazionario

Fulvio75

Well-Known Member
Licensed User
Ciao c'è un modo per conoscere se inserisco un numero frazionario?
Es.: Inserisco 1 mi deve dare false
Inserisco 1.5 mi deve dare true
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Dim i as Float = 1.5
Dim IsFrac as Boolean=i<>Floor(i)
log("E' frazionario: " & IsFrac)
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Dim i As Float = 1.5
Dim IsFrac As Boolean=i.As(String).Contains(".")
Log("E' frazionario: " & IsFrac)
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Dim i As Float = 1.5
Dim IsFrac As Boolean=(i Mod 1)>0
Log("E' frazionario: " & IsFrac)
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Dim i As Float = 1.5
Dim IsFrac As Boolean=Regex.IsMatch("\d+(.|,)\d+",i)
Log("E' frazionario: " & IsFrac)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…