Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 29-06-2008, 06:58 PM   #1 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Arrow Logic needed... decimal numbers


I need some help with VB coding.
I need to split the decimal part of a number and use it later. eg.input is 10.88, splitted to say num1=10 and num2=88 .
Can someone help me with the logic here.
arian29 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 29-06-2008, 07:18 PM   #2 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,772
Default Re: Logic needed... decimal numbers

suppose num=xx.yy
then
digit=0; // no of digits after decimal
num1=(int)num;
while(num!=(int)num)
digit++;
num2=num-num1*(10^digit);

//so num=num1.num2 now
__________________
My new blog: www.pathikshah.com
Pathik is offline  
Old 29-06-2008, 07:24 PM   #3 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Arrow Re: Logic needed... decimal numbers

Thanks Pathik
Code looks good for c/c++, however i am not sure how exactly i can implement it in VB ? any help here
arian29 is offline  
Old 29-06-2008, 07:35 PM   #4 (permalink)
Mad and Furious
 
redhat's Avatar
 
Join Date: May 2006
Location: Visual Basic 6.0
Posts: 453
Default Re: Logic needed... decimal numbers

try referring to this link, this is what u want:
http://www.developerfusion.co.uk/show/5957/3/
__________________
My new Tech Blog : http://technewspaper.blogspot.com/
redhat is offline  
Old 29-06-2008, 07:40 PM   #5 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,772
Default Re: Logic needed... decimal numbers

Nope. Don't know VB at all. Wait for the others.
__________________
My new blog: www.pathikshah.com
Pathik is offline  
Old 29-06-2008, 07:45 PM   #6 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: Logic needed... decimal numbers

Hmmm. eveb I don't know VB. But I can think of some logic:
1. Convert the number into string.
2. Split the string using '.' as sperator
3. Convert the split parts into integers again and use them.
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 29-06-2008, 08:06 PM   #7 (permalink)
Alpha Geek
 
adi007's Avatar
 
Join Date: Sep 2007
Location: hassan
Posts: 717
Default Re: Logic needed... decimal numbers

Well i know VB..
Which VB are u using..
VB 6 or latest version..?
__________________
doiteasily.com ►easy way(s) to do certain things
Tech Word of the day : ADSL
Aditech Blog ► There is something for everyone
Terminal Command of the day
regtweak.info ► Windows Registry hacks and tricks
adi007 is offline  
Old 29-06-2008, 08:20 PM   #8 (permalink)
Legen-wait for it-dary!
 
dheeraj_kumar's Avatar
 
Join Date: Dec 2004
Location: Chennai
Posts: 2,471
Default Re: Logic needed... decimal numbers

Yeah theres a way...

get the floor function from http://www.dreamincode.net/code/snippet178.htm

floor(10.88) = 10, it cuts down the number to the exponent(number before the dot) only.

To get the mantissa(number after the dot) subtract the floor value from the original number.

10.88 - floor(10.88) = 10.88 - 10 = 0.88

and multiply it by 100 to get 88, which is your num2.

so simply,

num1 = floor(10.88)
num2 = (10.88 - num1)* 100
__________________
If the Start Windows Restart when Windows starts check box is checked Windows Restart will start automatically every time Windows is started. - Actual excerpt from a windows program help file
dheeraj_kumar is offline  
Old 29-06-2008, 09:28 PM   #9 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Talking Re: Logic needed... decimal numbers

Quote:
Originally Posted by dheeraj_kumar View Post
Yeah theres a way...

get the floor function from http://www.dreamincode.net/code/snippet178.htm

floor(10.88) = 10, it cuts down the number to the exponent(number before the dot) only.

To get the mantissa(number after the dot) subtract the floor value from the original number.

10.88 - floor(10.88) = 10.88 - 10 = 0.88

and multiply it by 100 to get 88, which is your num2.

so simply,

num1 = floor(10.88)
num2 = (10.88 - num1)* 100
Seems to be working... Thanks dheeraj_kumar
@adi... its vb6
arian29 is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Decimal, Binary and Hexadecimal rohan Programming 22 02-01-2010 05:41 PM
Partition Logic - the free partitioning software Ponmayilal Reviews 9 24-11-2008 06:13 PM
How to get a Seagte HDD logic card 250GB pata longlife Hardware Q&A 1 23-02-2008 09:51 AM
[vb quest] convert a decimal to binary mach QnA (read only) 3 01-02-2006 04:36 PM
Where I can find drivers for my Avance logic ALS 120 onboard Uma009 QnA (read only) 3 25-08-2004 09:37 AM

 
Latest Threads
- by Sujeet
- by clmlbx
- by Sujeet
- by icebags

Advertisement




All times are GMT +5.5. The time now is 11:04 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2