473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How can I get INTeger from float


Folks,

If I have a number that includes decimal points and I want to remove
everything right of the decimal, how do I do it - I know I could explode
using the point as a delimiter but that doesn't look legal.

I've tried

$t=1.532;
$y=int($t);
but that didn't work out for me...

any ideas?

thanks
randelld
Jul 16 '05 #1
3 14742
Randell D. wrote:
If I have a number that includes decimal points and I want to remove
everything right of the decimal, how do I do it


floor()
Jul 16 '05 #2

"Dana" <Da**@nospamnexlab.it> wrote in message
news:bi**********@newsreader.mailgate.org...
Randell D. wrote:
If I have a number that includes decimal points and I want to remove
everything right of the decimal, how do I do it


floor()


Many thanks - I never heard of the function before nor would I have ever
guessed it.

Cheers.
Jul 16 '05 #3
Randell D. wrote:
"Dana" <Da**@nospamnexlab.it> wrote in message
news:bi**********@newsreader.mailgate.org...
Randell D. wrote:
If I have a number that includes decimal points and I want to remove
everything right of the decimal, how do I do it


floor()

Many thanks - I never heard of the function before nor would I have ever
guessed it.

Cheers.


you were close yourself anyway:

$t=1.532;
$y=(int)$t;

should work too

Jul 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: da Vinci | last post by:
Hi Gents, This is what I am trying to do. Say you have a double or a float with the value 14.5624 for example. How could I take that variable and get the 14 into an integer variable and the...
9
by: Darius Fatakia | last post by:
hi, i'm new to MS Visual Studio and C++ but not to C programming in general. i'm trying to divide two integers and get their actual quotient (eg 5/3 = 1.666667 etc). i thought i had type cast...
8
by: Brent Lievers | last post by:
Greetings, I have a question about parsing a fixed-width integer from a string. Lines of data are being read from a file having a very strict column-delimited format. In my example below,...
6
by: J.Marsch | last post by:
Suppose that I have an integer division problem, but I want the answer was a float. What's the cleanest syntax for that? Example: In this code, the variable z ends up == 0. And that is...
4
by: Geky | last post by:
Why when I multiply a float , for example X10, and than convert it as an integer the new value is changed? Example: float fl = 1.8 int x; x = int(fl * 10);
6
by: comp.lang.php | last post by:
I'm involved in a rather nasty debate involving a strange issue (whereby the exasperated tell me to RTFM even after my having done so), where this is insanely possible: print_r(is_int('1'));...
8
by: gk245 | last post by:
This is part of a bigger program, but i made it simple (basically the OT_hours function is supposed to determine if the number entered is over 40 hours or not and return the appropriate answer): ...
1
by: iulian.ilea | last post by:
I have this functions, c3 and c2 that computes and return a float number. The problem is that wen I pass the result of c2 (float number) to c3(), in function apears to be an integer. Ex.:...
17
by: arindam.mukerjee | last post by:
I was running code like: #include <stdio.h> int main() { printf("%f\n", 9/5); return 0; }
7
by: shellon | last post by:
Hi all: I want to convert the float number to sortable integer, like the function float2rawInt() in java, but I don't know the internal expression of float, appreciate your help!
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.