Re: Conversion Float => Integer

From: Date: Sat, 16 Sep 2017 21:30:04 +0000
Subject: Re: Conversion Float => Integer
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-326222@lists.php.net to get a copy of this message
On 16.09.2017 at 15:40, AshleySheridan wrote: > On Sat, 2017-09-16 at 16:36 +0300, Michelle Konzack wrote: > >> What is the easiest method to convert a Float to Integer? >> >> I have (only) to get rid of anything after the decimal point. > > There are a few ways: > > $int = intval($float); > $int = (int)$float; > $int = floor($float); It might be appropriate to point out that the latter has different results than the former two, if $float is a negative non-integral value, and that floor() returns a float. -- Christoph M. Becker

« previous php.general (#326222) next »