943,733 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Marked Solved
  • Views: 1590
  • ASP RSS
Jul 1st, 2008
0

ASP - Finding a Specific Number in an Integer

Expand Post »
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
Reputation Points: 49
Solved Threads: 11
Posting Whiz in Training
uniquestar is offline Offline
239 posts
since Feb 2005
Jul 10th, 2008
1

Re: ASP - Finding a Specific Number in an Integer

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.
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008
Jul 10th, 2008
0

Re: ASP - Finding a Specific Number in an Integer

That's Brilliant logic, Thanks!
Reputation Points: 49
Solved Threads: 11
Posting Whiz in Training
uniquestar is offline Offline
239 posts
since Feb 2005
Jul 11th, 2008
0

Re: ASP - Finding a Specific Number in an Integer

Hi,
If you have got the solution, can you please close this thread.
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: To write a text file in FTP server
Next Thread in ASP Forum Timeline: Where to run this ASP?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC