Where is the decimal point?

T

Tony Girgenti

Hello.

Working on a VS2005 SP1 Windows form program in .NET 2.0, on XP Pro, SP2.

I must be pretty stupid. I can't figure out how use decimal data in a table
where there is no decimal point. I populated the table with data from a
flat file that has a number like this "000001645000". Without the quotation
marks of course. The assumed decimal point is five digits from the right.
So that number shuould be 0000016.45000.

How do i use this decimal in a calculation as 16.45000. I'm not looking to
truncate any zeros, left or right, i just want to be able to use it as the
value it should be, 16.45. Also, i'm not looking to convert it to a string
as 16.45000. I know how to do that.

It is stored in the datatable as 1645000. I don't see a decimal point in
the table data.

Any help would be gratefully appreciated.

Thanks,
Tony
 
R

Rad [Visual C# MVP]

Hello.

Working on a VS2005 SP1 Windows form program in .NET 2.0, on XP Pro, SP2.

I must be pretty stupid. I can't figure out how use decimal data in a table
where there is no decimal point. I populated the table with data from a
flat file that has a number like this "000001645000". Without the quotation
marks of course. The assumed decimal point is five digits from the right.
So that number shuould be 0000016.45000.

How do i use this decimal in a calculation as 16.45000. I'm not looking to
truncate any zeros, left or right, i just want to be able to use it as the
value it should be, 16.45. Also, i'm not looking to convert it to a string
as 16.45000. I know how to do that.

It is stored in the datatable as 1645000. I don't see a decimal point in
the table data.

Any help would be gratefully appreciated.

Thanks,
Tony

If there is no decimal point in the data, and you're sure it will always be
5 digits from the right, you could divide your data by 100000 after you
import it to put the decimal point. Then you can use the numbers in your
calculations with a free hand
 
T

Tony Girgenti

Hello Rad.

OK. That worked.

I'm loading this data from a flat file. Now, i need to write the data back
out to another flat file. How do i format the number so that it always has
the same number of digits in the flat file?

Each record should look like this "BMR617JV 000001645000+". Where the
number is "000001645000+". I need it to always be the same number of digits
in the flat file.

Thanks,
Tony
 
R

Rad [Visual C# MVP]

Hello Rad.

OK. That worked.

I'm loading this data from a flat file. Now, i need to write the data back
out to another flat file. How do i format the number so that it always has
the same number of digits in the flat file?

Each record should look like this "BMR617JV 000001645000+". Where the
number is "000001645000+". I need it to always be the same number of digits
in the flat file.

Thanks,
Tony

Hey Tony,

To lose the decimal points when writing to the file just do the reverse --
*multiply* each number by 100000
 
C

Cor Ligthert [MVP]

Tony,

As alternative, write to a "decimal" value where is told where the point is.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top