how do I insert a decimal 2 spaces from the left?
K Ken Sheridan Aug 21, 2007 #3 Are you saying you want to take an integer of variable length e.g. 1234567 and return 12.34567? If so one way would be: NewNumber = OriginalNumber/10^(Int(log(OriginalNumber)/log(10))-1) Ken Sheridan Stafford, England
Are you saying you want to take an integer of variable length e.g. 1234567 and return 12.34567? If so one way would be: NewNumber = OriginalNumber/10^(Int(log(OriginalNumber)/log(10))-1) Ken Sheridan Stafford, England
K Ken Sheridan Aug 21, 2007 #4 PS: It would also work if the original number is a floating point number. Ken Sheridan Stafford, England
PS: It would also work if the original number is a floating point number. Ken Sheridan Stafford, England
J John W. Vinson Aug 21, 2007 #5 how do I insert a decimal 2 spaces from the left? Click to expand... What's the context? Do you want to take 3145 and get 31.45, 22458712 and get 22.458712 and so on? What's the datatype of the field? John W. Vinson [MVP]
how do I insert a decimal 2 spaces from the left? Click to expand... What's the context? Do you want to take 3145 and get 31.45, 22458712 and get 22.458712 and so on? What's the datatype of the field? John W. Vinson [MVP]
H helpme Aug 21, 2007 #6 Thank you everyone for your feedback. For instance it currently is 1234567 however it should be 12345.67. Another example is 123400 it should read 1234.00. It is currently saved as a text file.
Thank you everyone for your feedback. For instance it currently is 1234567 however it should be 12345.67. Another example is 123400 it should read 1234.00. It is currently saved as a text file.
D Douglas J. Steele Aug 21, 2007 #7 That's two digits from the right, not from the left, so it's simpler than Ken's suggestion. All you need to do is divide the number by 100.
That's two digits from the right, not from the left, so it's simpler than Ken's suggestion. All you need to do is divide the number by 100.
J Jamie Collins Aug 21, 2007 #8 That's two digits from the right All you need to do is divide the number by 100. Click to expand... Actually, I think they may want to multiply by 0.01 e.g. SELECT 1234567 / 100 AS float_value, TYPENAME(1234567 / 100) AS float_type, 1234567 * 0.01 AS decimal_value, TYPENAME(1234567 * 0.01) AS decimal_type In my experience, when someone specifies 'decimal' they are interested in exact values. Dividing by 100 returns an approximate type. Jamie. --
That's two digits from the right All you need to do is divide the number by 100. Click to expand... Actually, I think they may want to multiply by 0.01 e.g. SELECT 1234567 / 100 AS float_value, TYPENAME(1234567 / 100) AS float_type, 1234567 * 0.01 AS decimal_value, TYPENAME(1234567 * 0.01) AS decimal_type In my experience, when someone specifies 'decimal' they are interested in exact values. Dividing by 100 returns an approximate type. Jamie. --