473,383 Members | 1,798 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,383 software developers and data experts.

Drop fractional part of a number?

Helo,

There're so many methods for rounding in .NET, but I can't find any that
will just drop fractional part of a number, e.g: -3.9 => -3.

I tried:

CInt(-3.9)
Int(-3.9)
Math.Round(-3.9)
CType(-3.9, Integer)
Convert.ToInt32(-3.9)

But the all return me -4.

In C# it's simple: (int)-3.9 = -3. Is there any method to do this in VB.
NET?

Thanks.

Roman
Nov 21 '05 #1
3 7032
"Dragon" <no@spam.please> wrote in message news:eD**************@TK2MSFTNGP09.phx.gbl...
Helo,

There're so many methods for rounding in .NET, but I can't find any that
will just drop fractional part of a number, e.g: -3.9 => -3.

I tried:

CInt(-3.9)
Int(-3.9)
Math.Round(-3.9)
CType(-3.9, Integer)
Convert.ToInt32(-3.9)

But the all return me -4.

In C# it's simple: (int)-3.9 = -3. Is there any method to do this in VB.
NET?

Thanks.

Roman


Try Fix().

--
Al Reid
Nov 21 '05 #2
Wow! Now I feel stupid.

Thanks Al.
Nov 21 '05 #3
Dragon,
In addition to the other comments:

It sounds like you want "Truncation" & not rounding.

Have you looked at the following functions:
- Decimal.Truncate
- Math.Ceiling
- Math.Floor
- Fix
- Int

Hope this helps
Jay

"Dragon" <no@spam.please> wrote in message
news:eD**************@TK2MSFTNGP09.phx.gbl...
| Helo,
|
| There're so many methods for rounding in .NET, but I can't find any that
| will just drop fractional part of a number, e.g: -3.9 => -3.
|
| I tried:
|
| CInt(-3.9)
| Int(-3.9)
| Math.Round(-3.9)
| CType(-3.9, Integer)
| Convert.ToInt32(-3.9)
|
| But the all return me -4.
|
| In C# it's simple: (int)-3.9 = -3. Is there any method to do this in VB.
| NET?
|
| Thanks.
|
| Roman
|
|
Nov 21 '05 #4

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

Similar topics

5
by: Michael Søndergaard | last post by:
I Pascal there are a function for retriving the fractional part of a real number (Frac), I can't find any in the dotnet framework. The function needs to remove the integer part and keep only the...
14
by: axlq | last post by:
I am trying to figure out what is the minimal simplest CSS I can have to accomplish a row of tabs, with one or more tabs having a drop-down menu when you hover over it -- AND the whole tab+menu...
7
by: callawayglfr | last post by:
I am building a database in access where I have a drop down box that relates to a text box, that part I have working but when someone selects information from the first drop down I need it to limit...
2
by: djzbor | last post by:
Any who can help!! let i have a number 16.0230045 i want to count the fractional part of this number means i want to get the number of digits of the fractional part of this number and store each...
2
by: Bob | last post by:
Greetings All, Is there a simple way of suppressing the fractional part of a timespan At the moment I use one time span to populate another minus the fractional part .. this is a bit clunky. ...
10
by: schaefer.mp | last post by:
Does anyone know of an approximation to raising a negative base to a fractional exponent? For example, (-3)^-4.11111 since this cannot be computed without using imaginary numbers. Any help is...
12
by: bsabiston | last post by:
Hi, I'm trying to get the fractional part of a floating point number. I've tried fmod() and modf(), and while both do work, they also occasionally return 1.0 for the fractional part of the number...
0
by: Chris Rebert | last post by:
On Wed, Nov 19, 2008 at 10:01 PM, srinivasan srinivas <sri_annauni@yahoo.co.inwrote: Since you really care about significant figures here, have you considered using decimal rather than float as,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.