Jul 19, 2006 #1 stormbind Technical User Joined Mar 6, 2003 Messages 1,165 Location 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 Joined Aug 18, 2003 Messages 4,156 Location 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 Joined Jan 8, 2004 Messages 4,042 Location 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