DIGIT-ARC read-only archive · snapshot: July 23, 2026

Logic needed... decimal numbers

9 posts · originally from https://geek.digit.in/community/threads/logic-needed-decimal-numbers.91719/

A
arian29 Original post #1
Jun 29, 2008 at 6:58 PM
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. :)
Pathik
Pathik #2
Jun 29, 2008 at 7:18 PM
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
A
arian29 #3
Jun 29, 2008 at 7:24 PM
Thanks Pathik
Code looks good for c/c++, however i am not sure how exactly i can implement it in VB ? any help here :)
redhat
redhat #4
Jun 29, 2008 at 7:35 PM
try referring to this link, this is what u want:
*www.developerfusion.co.uk/show/5957/3/
Pathik
Pathik #5
Jun 29, 2008 at 7:40 PM
Nope. Don't know VB at all. Wait for the others.
victor_rambo
Jun 29, 2008 at 7:45 PM
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.
A
adi007 #7
Jun 29, 2008 at 8:06 PM
Well i know VB..:D :cool:
Which VB are u using..
VB 6 or latest version..?
dheeraj_kumar
Jun 29, 2008 at 8:20 PM
Yeah theres a way...

get the floor function from *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
A
arian29 #9
Jun 29, 2008 at 9:28 PM
Yeah theres a way...

get the floor function from *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