C# - Rounding To The Best Unit Without Losing Precision

Jan 26, 2010

I receive a decimal number with a maximum of 4 digits after the "." and I know this number is in milligram.

I have to find the best matching unit (milligram, gram, kilogram) for the number.

for an example if I receive

edited

116000000.0000 milligram, it's going to return 116.0000 kilogram
66990000.0000 milligram, it's going to return 66.9900 kilogram
49000010.0000 milligram, it's going to return 49000.0100 g

[Code]....

View 6 Replies


ADVERTISEMENT

Rounding Up To The Nearest (Unit 10)?

Jul 9, 2010

How do I go about rounding up to the nearest (Unit 10) ie Codes Below

IfVal(TimeHalfFareTextBox.Text = $/£ 0.05)
Then roundup
to $/£ 0.10. Or it might be .....

[Code]....

View 6 Replies

Application Which Communicate With One Data Logger Unit (temperature Monitoring Unit)

Jul 21, 2010

I have written one application which communicate with one data logger unit (temperature monitoring unit) and download records after some interval. Unit continuously send current temperature which I have to show on screen and after each one hour I have to download log (all records saved inside unit at max 1024) from unit.

Now problem is after downloading log, application get hang or what we called working in background and resume after some time. If I pause debugger in visual studio 2008 it show control at application start (sub main) with message as "application will resume here after completing execution of current function". There is nothing in output window. So how can i trace is there any events got spool or what actually application doing in background.

View 1 Replies

VS 2008 Unit Converter Handling Multiple Unit Types

Apr 12, 2011

Does anyone have a nice sample of a unit convertor handling multiple unit types that I can integrate in my application? I have found this one, but it is only handling one type of unit. For example I want to convert weight as well as volume from and to imperial units.

View 8 Replies

Dividing With Precision In .net?

Aug 3, 2011

I have a fairly small double and a fairly large double. When I divide the large one by the small one and display it with Console.WriteLine, it always shows exponential notation. Can I display the non exponential notation form?

View 2 Replies

Decimal And Double Precision

Jun 30, 2009

I am working on an application that allow the user to store data as numbers.These numbers are later on used for calculation. The number can be of any type and are saved as string. The problem is when they are used for calculation how can understand when it is better to treat them as doubles and when as decimals?

View 9 Replies

C# - Adding Two .NET SqlDecimals Increases Precision?

Jun 23, 2011

in .NET, when I add two SqlDecimals, like so:

[Code]...

then s3 has precision 2, whereas both s1 and s2 have precision 1. This seems odd, especially as the documentation states that the return value of the addition operator is "A new SqlDecimal structure whose Value property contains the sum." I.e. according to the documentation, addition should not change the precision.

View 2 Replies

Calculation Not Providing Correct Precision?

Aug 19, 2009

Consider the following :

Dim Length1 As Double = (10* 12) + 5
Dim SqFt1 As Double = 0.0
Dim length2 As Double = Length1 / 12.0
Dim tape As Double = CType(210.0, Double)
'Length2 at this point has a value = 10.41666
SqFt1 = CType(length2 * tape, Double)

[Code]...

View 5 Replies

Data Type Precision In Oledbdata Reader

Oct 13, 2009

I exported xlxs files to sql server using oledb data reader. I'm using visual studio 2005. [code]

View 3 Replies

Use Numbers With A Precision Of Hundreds Of Decimal Places?

Mar 21, 2011

I want to use numbers with a precision of hundreds of decimal places.

I know of the BigInteger datatype for ints, but System.Numerics falls short beyond the decimal.

How can I achieve anything beyond a simple Decimal/Double precision in vb.net?

View 2 Replies

Change A Double To A Precision Of 2 Places To The Right Of Decimal Point?

Nov 22, 2009

how to get 1.83333333333... to 1.83?

Dim temp_1 As String
temp_1 = 5.50 / 3

Label1.Text = String.Format(temp_1, "{0.00}")

View 4 Replies

LINQ Query With Sum And Group By Is Adding Decimal Precision

Aug 24, 2009

I am trying to do a simple summary of table data using a LINQ query.a regular SQL Query looks like:[code]This query works fine and returns the correct results.[code]This LINQ query returns the incorrect results some of the time. Off by .01 in most cases.The "value" column is of type Numeric (12,2) in the database.Now when I show the values from the Sum in a msgbox I get extra precision and thus incorrect results as my end result because of rounding.For example I get 835.18 + 54.62 = 889.80960 from the above LINQ query.I am running Visual Studio 2008 9.0.30729.1 SP on Vista 64Bit with .NET 3.5 SP1.

View 3 Replies

Reading Double Precision Values From Binary File?

Feb 19, 2010

I am attempting to read a series of double prcision float values (x,y,z coordinates) from a binary file using the binary reader. Everything works fine except that when I read the number back it is different then the number that was written there (original file is generated by mining application).

written number : 78897.6476586
file contents hex : 40 F3 43 1A 5C CF 43 A4 this converts back to the same number as written using a IEE 754 conversion program. VB returned value : -5.45100266729248E-134 using .readDouble()

I have tried to step thru the file in one byte steps to make sure that I have the proper start position but that did not help any.

View 2 Replies

RoundUp Function - Which Will Round A Number UP To The Specified Decimal Precision

Apr 29, 2009

I need a function which will Round a number UP to the specified decimal precision, exactly the same as how Excel's RoundUp function works:

Roundup(dblVal, intDecPlaces)

So I need the following:

Roundup(0.896523, 4)
would return
0.8966

However, everything i've tried/found simply rounds to the nearest whole integer, or returns a normal rounded value, hence the above would return
0.8965

I've tried the following:

Math.Round(dblval, intPrecision, midpointrounding.awayfromzero)
' and
Math.Round(dblval, intPrecision, midpointrounding.toeven)

And even custom functions, such as:

Public Function RoundUp(ByVal varValue As Object, _
ByVal iNum As Integer) As Double

'ignore the data types here, I was playing to see 'if changing any of the data types would swing 'the results (knowing full well they wouldnt make 'a difference, thats how fed up with this I am!)

Dim lNum As Long, xVal As Double, xVar As Object

xVar = Fix(varValue)

[CODE]...

I've even looked at converting this to a string, looking at the Xth decimal place, and incrementing it up by 1, then converting it back to a double, while this works (sort of) it seems to be a very roughshod way of doing it, and I'd rather do it mathematically than with lots of data conversion.

View 6 Replies

Store Oracle TimeStamp Precision 6 In SQL Server DateTime?

Feb 16, 2012

I've a scenario where I've to move data from a Oracle Table to a SQL Server table. The column in Oracle is Timestamp(6) 6 being the precision. Now I cannot send the Oracle Data in string format. I pull the data straight from the Oracle Table, so cannot format it on oracle side. What I can do is format the data using VB6.Format to make it suitable for SQL Server DateTime. I'm doing this for Oracle Date to SQL Server Datetime

View 1 Replies

Storing Oracle TimeStamp Precision 6 In SQL Server DateTime

Apr 20, 2011

I've a scenario where I've to move data from a Oracle Table to a SQL Server table. The column in Oracle is Timestamp(6) 6 being the precision. Now I cannot send the Oracle Data in string format. I pull the data straight from the Oracle Table, so cannot format it on oracle side. What I can do is format the data using VB6.Format to make it suitable for SQL Server DateTime. I'm doing this for Oracle Date to SQL Server Datetime. Can something similar be done for timestamp and Datetime.

View 1 Replies

Writing An Array Of Single-precision Floats In One Operation

Sep 19, 2009

I am making the belated transition from VB6 to VB.NET (2008). I would appreciate some guidance on writing arrays to a file. I need to save and load large arrays of 4-byte floats (24 x 90,000 values is not uncommon). I can load or save them using nested for-next loops, but that's quite slow. I'd like to find a single operation that can read or write the binary data.In VB6 I could accomplish this (writing case shown) with Put #1 , , MyArray()I can read and write single variables from binary files without problems in .net. For example, [code]I have looked and looked, and Googled endlessly, but cannot find out how to accomplish a single-line numeric, floating-point array read or write in VB.NET.

View 3 Replies

Convert Single Precision Floating Point Numbers To IEEE 754 Hex And Back?

Aug 12, 2009

Private Function SingleToIEEE754Hex(ByVal pValue As Single) As String

[Code]...

View 1 Replies

Microsoft Data Access Application Block Date Type Precision?

Jul 13, 2009

We are working on an ASP.Net/VB.Net application using Enterprise Library for our data access (DAAB).

We are trying to store DateTime values in an Oracle Date field. However, the precision is being lost. Currently only the year, month, and date are being stored. We need better precision than this.

Oracle Dates are supposed to "includes not just the month, day, and year, but also
the hour, minute, and second. "

View 1 Replies

.net - Losing Data Continued?

Jan 20, 2011

This procedure is inside of the xsd file:

Public Shared Sub AddRowData(ByVal sender As Object, ByVal e As System.EventArgs)
Dim myDataCol As DataColumn
Dim myDataRow As DataRow

[code]....

Before it leaves the procedure I'm checking the DataSet row and I see that the Variable are there.In the next step it goes to a form on which I'm viewing the relative report.The Last form has only the Load event, nothing else. there is no any row .

View 1 Replies

C# - WPF: Control Losing Its Binding?

Nov 26, 2010

I have a MenuItem of a context menu of a Grid and its IsEnabled property is bound to MyProperty. It works fine until I actually click on the event handler of the MenuItem, which has no code in it. After I have clicked on the MenuItem the dataBinding no longer works.

I can tell cos' my breakpoint in the getter of MyProperty does not get hit.

[Code]...

View 2 Replies

Gridview Losing The Format?

Jun 10, 2012

Having a problem with Gridview losing it's column width, font, headings, etc when attempting to change font/color when null fields exist.

Here's my code that works correctly

HTML

'>>==== Highlight a Row after grid is sorted ======
'can be used to show 'over budget' items highlited in Red Italics
For i = 0 To DgvGrid.Rows.Count - 1
If Not IsDBNull(DgvGrid.Rows(i).Cells("BudYtd").Value) Then 'Only test Non-Null Values

[code].....

View 5 Replies

Listview Losing Listviewitems?

Dec 6, 2009

Here's an interesting issue:I've got a listview on a form that will load up properly, but as soon as I get my proxy (multithreaded) going, the listviewitems inside the listview suddenly cease to exist.

View 5 Replies

Losing Focus On Other Applications?

Nov 18, 2010

I've written a short application that consists of a form, listviewbox and a timer, the program sits in the taskbar with the form invisible, the timer is set for 40 seconds and basically it queries a database held on an SQL 2000 server, when a certain change happens within the database my form pops up and shows some data in the listview, this happens well, the problem I have is when the check is going on (every 40 seconds) the user loses focus on what ever they're working on. Is there a way I can stop this?

View 2 Replies

Losing Value Outside Of Databinding Expression

Oct 21, 2009

When I call a function, it doesn't retain the return value for use later on in the script. How do you keep a value from something that's called within the <%# %> databinding expression?
<%#GetGoal(DataBinder.Eval(Container.DataItem, "GoalName"))%>
GetGoal just returns a string based on the value of a databound item. The reason I'm using this approach is because this is within a repeater and each row is different.
[URL]

<script runat="server">
Public Function GetGoal(ByVal Goal As Object) As String
Dim tmpControl As UserControl = LoadControl(lblLastGoal)
Page.Controls.Add(tmpControl)
If (Goal <> lblLastGoal.Text) Then
[Code] .....

View 2 Replies

New Processes And Losing Focus?

Apr 19, 2009

I need to start multiple processes, with minimized windows - and I don't want whatever the current process is to lose focus.Something like this should be simple enough:

[Code]...

However, whatever application is running will lose focus when this code is executed. I've looked high and low, and there doesn't seem to be any relatively simple way to do this. I had some ideas about capturing whatever application has focus (I don't want to assume my program has focus), then running the above code, and then restoring focus. However, I'm fairly certain this will require win32 API calls, and I'm not sure how to do that.

View 4 Replies

Time - Timer In .NET Is Losing One Second

May 6, 2012

I use a DateTimePicker to pick a dateTime value and see how much time I have until it is zero: [Code] The timer is set to make changes each one second. What Can I do to have the right results?

View 2 Replies

Why Does The Msgbox Keep Losing Focus

Jan 23, 2011

code...

Dim sqlConn As New SqlConnection("server=.SQLEXPRESS;Integrated Security=true; Database=memberlist;")
sqlConn.Open()
Dim sqlComm As New SqlCommand("SELECT * FROM memberlist", sqlConn)

[code]....

when i do this the first msgbox pops up, i click ok, it then loses focus, i think its actually minimizing. I then have to click it in the task bar several times to get it to come back up. from then it will sometimes give each msgbox over and over just fine, sometimes it will minimizes random ones. the first one seems to be a constant.

View 5 Replies

.net - Rounding To Next Whole Number?

Dec 15, 2009

if i have an integer a_variable = 1.1 how do i round it up to 2?

View 2 Replies

.net Rounding To Whole Number?

Sep 12, 2011

I have very basic question, I'm really not familiar with vb.net.

I have code like this: Dim minutes As Integer = (55 / 60)

I want this to return 0 to me, integer 0 (no decimals), but vb.net rounds this to 1.

Can someone hint me up how to accomplish this ?

edit. OK for those with same problem try dividing with (Yeah, it's not escape character in vb.net)

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved