473,498 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting integer from decimal

Hello

I have a method that returns a decimal. I need to get the lowest integer
value from this decimal. For example from "4.9764" I need to get "4", or
from "13.134" I need "13". Is there a .Net method I can use to do this? If
not, maybe someone throw me a tidbit of code to so this..

TIA
Steve
Nov 21 '05 #1
5 1567
theInteger = CInt(theValue)

"Steve Peterson" <sp*******@nospam.com> wrote in message
news:ey**************@tk2msftngp13.phx.gbl...
Hello

I have a method that returns a decimal. I need to get the lowest integer
value from this decimal. For example from "4.9764" I need to get "4", or
from "13.134" I need "13". Is there a .Net method I can use to do this? If
not, maybe someone throw me a tidbit of code to so this..

TIA
Steve

Nov 21 '05 #2
Steve,

Depending on how you need to handle negative numbers, you might use the INT
function or the FIX function.

Kerry Moorman
"Steve Peterson" wrote:
Hello

I have a method that returns a decimal. I need to get the lowest integer
value from this decimal. For example from "4.9764" I need to get "4", or
from "13.134" I need "13". Is there a .Net method I can use to do this? If
not, maybe someone throw me a tidbit of code to so this..

TIA
Steve

Nov 21 '05 #3
Thx guys!
Steve

"Steve Peterson" <sp*******@nospam.com> wrote in message
news:ey**************@tk2msftngp13.phx.gbl...
Hello

I have a method that returns a decimal. I need to get the lowest integer
value from this decimal. For example from "4.9764" I need to get "4", or
from "13.134" I need "13". Is there a .Net method I can use to do this? If
not, maybe someone throw me a tidbit of code to so this..

TIA
Steve

Nov 21 '05 #4
"Steve Peterson" <sp*******@nospam.com> schrieb:
I have a method that returns a decimal. I need to get the lowest integer
value from this decimal. For example from "4.9764" I need to get "4", or
from "13.134" I need "13". Is there a .Net method I can use to do this? If
not, maybe someone throw me a tidbit of code to so this..


Take a look at 'Int', 'Fix', and 'Math.Floor'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
Hi, this is from the MSDN library that might help to clarify things:

When the fractional part is exactly 0.5, CInt and CLng always round it to
the nearest even number. For example, 0.5 rounds to 0 and 1.5 rounds to 2.
CInt and CLng differ from the Fix and Int functions, which truncate, rather
than round, the fractional part of a number. Also, Fix and Int always return
a value of the same type as is passed in.
"Steve Peterson" <sp*******@nospam.com> skrev i melding
news:ey**************@tk2msftngp13.phx.gbl...
Hello

I have a method that returns a decimal. I need to get the lowest integer
value from this decimal. For example from "4.9764" I need to get "4", or
from "13.134" I need "13". Is there a .Net method I can use to do this? If
not, maybe someone throw me a tidbit of code to so this..

TIA
Steve


Nov 21 '05 #6

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

Similar topics

6
10521
by: Peter Blatt | last post by:
Does 5 represent the total numer of digits (including the fractional portion) or only the number of places BEFORE the decimal point? Moreover does the number include the decimal point? Are there...
1
8208
by: Robin Tucker | last post by:
As I had real problems working my head around sp_spaceused, I've written an SP to do it (I also noted a lot of questions about this when "searching"). Pass in a database name and it will return the...
6
3677
by: Aaron | last post by:
I'm trying to get an average of a long and a std::vector::size_type, but keep getting 0 for some reason. I've tried the following: float avg = some_long / some_vec.size(); float avg =...
1
1476
by: bigcjr44 | last post by:
I have an assignment do tonite and I can not get it started. We are learning about recursion. This is my assignment, and this is what I have written, could someone please tell me what I am doing...
3
19215
by: stevek | last post by:
How do I format an integer. Add commas. 1234565 1,234,565 TIA
4
9708
by: italia | last post by:
I changed the Fieldsize Property from text to Long Integer and Decimal Places = 6. I had decimals in the original field. But after the transfer, the digits after the decimals are gone. Now...
17
3710
by: henrytcy | last post by:
Hi, How can I get a digit from integer for example, 12311, one by one for comparision? Thanks!
11
9980
by: ChrisM | last post by:
Hi Guys, I'm looking for a function that will return the lowest integer that is greater than or equal to a decimal number. eg. 3.1(decimal) returns 4(integer) 3.9(decimal) returns...
6
12897
by: kimiraikkonen | last post by:
Hi, Sorry if this is so basic but i wanted to know the correct way of displaying a value's "only" integer part. I mean; if i declare a value as integer which is actually a decimal number, it...
0
7125
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
7002
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
7379
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...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.