Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,868 questions

51,791 answers

573 users

How to generate random float number between 0 and 1 in Swift

1 Answer

0 votes
var number: Float = 0.0;
var i: Int = 0;
		
while (i < 10) {
    number = Float.random(in: 0..<1)
	print(number);
	i += 1;
}	


	
	
/*
run:

0.40625304
0.009013295
0.45786554
0.36523098
0.051380992
0.78078425
0.9652792
0.8403535
0.7751122
0.1600402

*/

 



answered Oct 14, 2021 by avibootz

Related questions

1 answer 91 views
1 answer 95 views
1 answer 85 views
3 answers 314 views
1 answer 169 views
1 answer 314 views
3 answers 377 views
...