#27433 [Opn]: (float) to (int) error

From: Date: Sun, 29 Feb 2004 02:43:12 +0000
Subject: #27433 [Opn]: (float) to (int) error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-55687@lists.php.net to get a copy of this message
ID: 27433 User updated by: ghetalion at ghetalion dot com Reported By: ghetalion at ghetalion dot com Status: Open Bug Type: Variables related Operating System: Linux PHP Version: 4.3.4 New Comment: Set this into the function when declaring it: TimeToText(1072224000); And you will get the expected/actual result I defined. Previous Comments: ------------------------------------------------------------------------ [2004-02-28 21:39:51] ghetalion at ghetalion dot com Description: ------------ When attempting to take a float variable and typecasting it into an int, I receive a magnificent error that is unexplainable. Reproduce code: --------------- function TimeToText($timestamp) { $day = strftime("%d", $timestamp); $factor = $day/10; $factor = (int)(($factor- ((int)($factor)))*10); var_dump($factor); } Expected result: ---------------- int(3) Actual result: -------------- int(2) Instead of truncating all decimal places, converting a float into an int is changing the entire whole-number value! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27433&edit=1

« previous php.bugs (#55687) next »