954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ASP - Finding a Specific Number in an Integer

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

uniquestar
Posting Whiz in Training
245 posts since Feb 2005
Reputation Points: 49
Solved Threads: 11
 

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.

vicky_rawat
Junior Poster
137 posts since Jun 2008
Reputation Points: 28
Solved Threads: 19
 

That's Brilliant logic, Thanks!

uniquestar
Posting Whiz in Training
245 posts since Feb 2005
Reputation Points: 49
Solved Threads: 11
 

Hi,
If you have got the solution, can you please close this thread.

vicky_rawat
Junior Poster
137 posts since Jun 2008
Reputation Points: 28
Solved Threads: 19
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You