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 3 2084
Dim MyNumber as Single = 4.1
Dim MyWholeNumber as Integer = Math.Ceiling(My Number)
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
Many many thanks, it worked
You are wounderful
Thanks & Best Regards
"Charlie Brown" <cb****@duclaw. comwrote in message
news:11******** **************@ 79g2000cws.goog legroups.com...
Dim MyNumber as Single = 4.1
Dim MyWholeNumber as Integer = Math.Ceiling(My Number)
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
"Hazem" <ha*********@gm ail.comwrote in message
news:%2******** *******@TK2MSFT NGP02.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
Two approaches come to mind. Both are illustrated below:
---------------------------------------------------------
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.WriteLi ne()
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(Nu mber, 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.WriteLI ne(Scratch & ": " & Major & " + " & Minor & _
" = " & Combined)
End Sub
Private Sub Print_Combined_ Digits_2(Number As Single)
Dim Scratch As String = FormatNumber(Nu mber, 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.WriteLI ne(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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Travis Stewart |
last post by:
Hi,
I am not very familiar with C++ so the problems I am having might be
simple and I just cannot see them or I am totally unaware of why something
would be incorrect. Anyway, I'm using the ANN approximate nearest
neighbour libraries written by David Mount and Sunil Arya. In the ANN.h
file there is a comment describing how the data types used to represent
the coordinates and distances between points can be modified by the user.
For my...
|
by: boblotz2001 |
last post by:
For anybody that implemented fuzzy searches in SQL Server or any other
database for that matter. I have implemented edit distance algorithm,
specifically q-grams, in SQL Server and wanted to get some opinions
from anyone who used a similar algorithm in a DBMS.
We are looking to implement fuzzy address search and are employing
number of different techniques including synonyms for strings like
"drive", "dr", "drv", etc... Number...
|
by: Paul Eggert |
last post by:
CBFalconer <cbfalconer@yahoo.com> writes:
> It would be fairly easy to graft such a construct with:
>
> enum subrangetype {MINVAL .. MAXVAL};
>
> where MINVAL and MAXVAL are constant integral values.
Suppose you need an integer type "foo" that can represent MINVAL,
MAXVAL, and all values in between. Will the following type do?
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |