I have a database field that is the product of a multiply in a sql statement
and it sometimes has 5 or more decimal places. I want to truncate beyond
the 2nd decimal place(###.##). I figured a Ctype to a decimal value would
do that but the four decimal places remain. I found a truncate function but
it only truncates to whole numbers. how can I do the truncation?
Thanks,
G 5 23939
There are other ways, but you could multiply by 100, truncate, then divide
by 100
"GaryB" <gb@nospam.co m> wrote in message
news:OW******** ******@TK2MSFTN GP15.phx.gbl... I have a database field that is the product of a multiply in a sql statement and it sometimes has 5 or more decimal places. I want to truncate beyond the 2nd decimal place(###.##). I figured a Ctype to a decimal value would do that but the four decimal places remain. I found a truncate function but it only truncates to whole numbers. how can I do the truncation? Thanks, G
* "GaryB" <gb@nospam.co m> scripsit: I have a database field that is the product of a multiply in a sql statement and it sometimes has 5 or more decimal places. I want to truncate beyond the 2nd decimal place(###.##). I figured a Ctype to a decimal value would do that but the four decimal places remain. I found a truncate function but it only truncates to whole numbers. how can I do the truncation?
Take a look at 'Math.Round', 'Math.Floor', and 'Math.Ceiling'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
" Just Me" <ne********@a-znet.com> wrote in
news:O7******** ******@TK2MSFTN GP12.phx.gbl: There are other ways, but you could multiply by 100, truncate, then divide by 100
Just use Math.round.
--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying. http://members.ebay.com/aboutme/coolspot18/
Hi,
Take a look at the numberformatinf o class.
Dim decTest As Decimal = CDec(5.0001)
Dim niDec As New System.Globaliz ation.NumberFor matInfo
niDec.NumberDec imalDigits = 4
Debug.WriteLine (decTest.ToStri ng(niDec))
Ken
-----------------------
"GaryB" <gb@nospam.co m> wrote in message
news:OW******** ******@TK2MSFTN GP15.phx.gbl...
I have a database field that is the product of a multiply in a sql statement
and it sometimes has 5 or more decimal places. I want to truncate beyond
the 2nd decimal place(###.##). I figured a Ctype to a decimal value would
do that but the four decimal places remain. I found a truncate function but
it only truncates to whole numbers. how can I do the truncation?
Thanks,
G
Hi,
Sorry bad example.
Dim decTest As Decimal = CDec(5.0001)
Dim niDec As New System.Globaliz ation.NumberFor matInfo
niDec.NumberDec imalDigits = 2
Debug.WriteLine (decTest.ToStri ng("f", niDec))
Ken
----------------
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:eF******** ******@TK2MSFTN GP12.phx.gbl...
Hi,
Take a look at the numberformatinf o class.
Dim decTest As Decimal = CDec(5.0001)
Dim niDec As New System.Globaliz ation.NumberFor matInfo
niDec.NumberDec imalDigits = 4
Debug.WriteLine (decTest.ToStri ng(niDec))
Ken
-----------------------
"GaryB" <gb@nospam.co m> wrote in message
news:OW******** ******@TK2MSFTN GP15.phx.gbl...
I have a database field that is the product of a multiply in a sql statement
and it sometimes has 5 or more decimal places. I want to truncate beyond
the 2nd decimal place(###.##). I figured a Ctype to a decimal value would
do that but the four decimal places remain. I found a truncate function but
it only truncates to whole numbers. how can I do the truncation?
Thanks,
G This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Bentley |
last post by:
John Bentley:
INTRO
The phrase "decimal number" within a programming context is ambiguous. It could
refer to the decimal datatype or the related but separate concept of a generic
decimal number. "Decimal Number" sometimes serves to distinguish Base 10
numbers, eg "15", from Base 2 numbers, Eg "1111". At other times "Decimal
Number" serves to...
|
by: Carl G |
last post by:
I am storing a 0.000 a System.Decimal in a DataRow.
On retrieval the value is only 0 without the three decimal places.
It looks like the Get property returns System.Decimal.Zero, but
why????
I can't figure out why the design is so that the DataRow "alters" the
value entered.
In my application a decimal column in a row of a specific table...
|
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 even after I have change the Fieldsize propert to Decimal with
Scale = 2, the digits after the decimal are not seen.
For eg. If the text was 16.27....
|
by: nick |
last post by:
printf("%lf",3.25);
the result is 3.25000
i want the answer correct to 3 decimal places
What should i do?
thanks!
|
by: VISHNU VARDHAN REDDY UNDYALA |
last post by:
Hello,
Can someone over here help me in truncating a float variable.
I mean if PI=3.14159 ...How can I get to read the first two or first
three decimal values with out rounding them. Any suggestions are
appreciated. I am BEGINNER TO C PROGRAAMING. Thanks
| |
by: cj |
last post by:
I want 7 * .105263 to result in an int32 value of 0. and 7 * .189021 to
result in an int32 value of 1.
I don't want to round. How can I just drop the decimal places?
|
by: prakashdehury |
last post by:
can some one pls suggest me why?
StreamWriter sw = new StreamWriter(@"c:\Temp\1.txt");
double dd1;
double dd2;
double dd3;
double dd4;
dd1 = 1452.123456789876123456;
dd2 = 1452.123456789123123456;
dd3 = 1452.123456789567123456;
|
by: Todd |
last post by:
I have a function that takes a double and truncates it to a specified
number of decimal places. I've found that I have to add a small
number to the input value otherwise I get errors due to the way
floating points work.
double TruncateToDigits(double dValue, int iDigitsToRightOfDecimal)
{
double dEpsilon = 1e-8;
// high limit, about...
|
by: Serenityquinn15 |
last post by:
Hi!
I have a little trouble about in truncating numbers. What i want to do is to get the two decimal places.
here's the example:
when i try to get the half of 20500.39 it shows like this:10250.195
but what i want to see is 10250.19 only.
another one is 20500.42, it shows like this: 10250.2
which in real, it must be 10250.21.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |