|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how 2 approximate 0.1 to be 1Hi, I want to make a calculation & need to appriximate
any fraction after the point to be added as genuine like 4.1 = 5 what function or syntax can I use to accomplish that in VB.net ?? Thanks Hazem Dim MyNumber as Single = 4.1
Dim MyWholeNumber as Integer = Math.Ceiling(MyNumber) Hazem wrote: Show quoteHide quote > Hi, I want to make a calculation & need to appriximate > > any fraction after the point to be added as genuine > > like 4.1 = 5 > > what function or syntax can I use to accomplish that in VB.net ?? > > Thanks > > Hazem Many many thanks, it worked
You are wounderful Thanks & Best Regards Show quoteHide quote "Charlie Brown" <cbr***@duclaw.com> wrote in message news:1165597166.323671.200980@79g2000cws.googlegroups.com... > Dim MyNumber as Single = 4.1 > Dim MyWholeNumber as Integer = Math.Ceiling(MyNumber) > > > Hazem wrote: >> Hi, I want to make a calculation & need to appriximate >> >> any fraction after the point to be added as genuine >> >> like 4.1 = 5 >> >> what function or syntax can I use to accomplish that in VB.net ?? >> >> Thanks >> >> Hazem >
Show quote
Hide quote
"Hazem" <hazem.mo***@gmail.com> wrote in message Two approaches come to mind. Both are illustrated below:news:%23CeLxiuGHHA.420@TK2MSFTNGP02.phx.gbl... : Hi, I want to make a calculation & need to appriximate : : any fraction after the point to be added as genuine : : like 4.1 = 5 : : what function or syntax can I use to accomplish that in VB.net ?? : : Thanks : : Hazem --------------------------------------------------------- Option Strict Imports System Public Module [module] PUblic Sub Main Print_Combined_Digits_1(4.0) Print_Combined_Digits_1(4.1) Print_Combined_Digits_1(4.2) Print_Combined_Digits_1(4.3) Print_Combined_Digits_1(4.4) Print_Combined_Digits_1(4.5) Print_Combined_Digits_1(4.6) Print_Combined_Digits_1(4.7) Print_Combined_Digits_1(4.8) Print_Combined_Digits_1(4.9) Print_Combined_Digits_1(5.0) Console.WriteLine() Print_Combined_Digits_2(4.0) Print_Combined_Digits_2(4.1) Print_Combined_Digits_2(4.2) Print_Combined_Digits_2(4.3) Print_Combined_Digits_2(4.4) Print_Combined_Digits_2(4.5) Print_Combined_Digits_2(4.6) Print_Combined_Digits_2(4.7) Print_Combined_Digits_2(4.8) Print_Combined_Digits_2(4.9) Print_Combined_Digits_2(5.0) End Sub Private Sub Print_Combined_Digits_1(Number As Single) Dim Scratch As String = FormatNumber(Number, 1) Dim Major As Integer = CInt(Int(Number)) Dim Minor As Integer = CInt(Int(Number * 10)) Mod (Major * 10) Dim Combined As Integer = Major + Minor Console.WriteLIne(Scratch & ": " & Major & " + " & Minor & _ " = " & Combined) End Sub Private Sub Print_Combined_Digits_2(Number As Single) Dim Scratch As String = FormatNumber(Number, 1) Dim Digits() As String = Split(Scratch, ".") Dim Major As Integer = CInt(Digits(0)) Dim MInor As Integer = CInt(Digits(1)) Dim Combined As Integer = Major + Minor Console.WriteLIne(Scratch & ": " & Major & " + " & Minor & _ " = " & Combined) End Sub End Module --------------------------------------------------------- This generates the following output: 4.0: 4 + 0 = 4 4.1: 4 + 1 = 5 4.2: 4 + 2 = 6 4.3: 4 + 3 = 7 4.4: 4 + 4 = 8 4.5: 4 + 5 = 9 4.6: 4 + 6 = 10 4.7: 4 + 7 = 11 4.8: 4 + 8 = 12 4.9: 4 + 9 = 13 5.0: 5 + 0 = 5 4.0: 4 + 0 = 4 4.1: 4 + 1 = 5 4.2: 4 + 2 = 6 4.3: 4 + 3 = 7 4.4: 4 + 4 = 8 4.5: 4 + 5 = 9 4.6: 4 + 6 = 10 4.7: 4 + 7 = 11 4.8: 4 + 8 = 12 4.9: 4 + 9 = 13 5.0: 5 + 0 = 5 Ralf
Interlocked.Add Not Thread Safe with Longs on a 32bit system
Data Relations with DataTable Class Data access layer for SQL Server & MS Access Is it possible to display images on desktop (not as an icon)? vbQuestion error Re: Which do you prefer? Reading int64 from file & converting to DateTime WebBrowser control in vb Re: where is the new access 2007 newsgroup? Inverse Text. |
|||||||||||||||||||||||