ASP - Finding a Specific Number in an Integer

Thread Solved

Join Date: Feb 2005
Posts: 238
Reputation: uniquestar is an unknown quantity at this point 
Solved Threads: 11
uniquestar's Avatar
uniquestar uniquestar is offline Offline
Daniweb Sponsor

ASP - Finding a Specific Number in an Integer

 
0
  #1
Jul 1st, 2008
Hi,

I about to write some code, that will, in the end, format some HTML.

To keep storage space down, the idea is to hold the number as an integer, and pick out the character that relates to the specific format when writing it. My problem however comes when trying to pick out the character.

The idea is to divide the number by a multiple of 10, and take the first number to the right of the decimal place, that way, if no formatting is t be applied, the integer can be 0, and each division will therefore also be 0, saving space in the database.

Can anybody help me with a way of finding the number to the left of the Decimal Place?

Thanks,

uniquestar
Tip of the Millenium: There is no point worrying about life, because no-one gets out alive.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: ASP - Finding a Specific Number in an Integer

 
1
  #2
Jul 10th, 2008
Hi,

you can use the following logic.

suppose the number is 123.567

take 2 integer variables say a and b and 2 float variables say c and d.

now c=123.567
a = c
this will store integer part in a.
now do d = c-a

so d will have .567
and a will have 123

to get digits from a.
divide a with 10 each time and the reminder will be the digit.

to get digits from d
multiply d with 10 and each time you will get one digit.

I hope this will solve your problem.
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 238
Reputation: uniquestar is an unknown quantity at this point 
Solved Threads: 11
uniquestar's Avatar
uniquestar uniquestar is offline Offline
Daniweb Sponsor

Re: ASP - Finding a Specific Number in an Integer

 
0
  #3
Jul 10th, 2008
That's Brilliant logic, Thanks!
Tip of the Millenium: There is no point worrying about life, because no-one gets out alive.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: ASP - Finding a Specific Number in an Integer

 
0
  #4
Jul 11th, 2008
Hi,
If you have got the solution, can you please close this thread.
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC