Jul 19, 2006 #1 stormbind Technical User Mar 6, 2003 1,165 GB hi, title says it all really. how do i convert a float into an int? cheers. --Glen Memoria mihi benigna erit qui eam perscribam
hi, title says it all really. how do i convert a float into an int? cheers. --Glen Memoria mihi benigna erit qui eam perscribam
Jul 19, 2006 #2 kaht Programmer Aug 18, 2003 4,156 US Code: int a; float b = 3.141592654; a = (int) b; -kaht Looking for a puppy? [small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small] Upvote 0 Downvote
Code: int a; float b = 3.141592654; a = (int) b; -kaht Looking for a puppy? [small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
Jul 20, 2006 #3 Diancecht Programmer Jan 8, 2004 4,042 ES That truncates the float, doesn't it? You can use Math.round to get the nearest int, but remeber that you will always lose the decimal part. Cheers, Dian Upvote 0 Downvote
That truncates the float, doesn't it? You can use Math.round to get the nearest int, but remeber that you will always lose the decimal part. Cheers, Dian