dbTalk Databases Forums  

decimal places with numbers

comp.databases.paradox comp.databases.paradox


Discuss decimal places with numbers in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jonathan
 
Posts: n/a

Default decimal places with numbers - 04-19-2007 , 11:33 AM






In a table there is a field called concentration.
It is a Number field.
The numbers vary from 0.025 to 200
When I look at the table in a record whose concetration field has a
value of 0.025, I see 0.03.
If I click on it it shows me the 0.025. No problems there.
In my code I have the following:
NuConcentration = TC.Concentration
If I view nuConcetration I see 0.03
More importantly, when the math is done (numbers X numbers) it is as
if it 0.03.
I need the precision.
Any suggestions?
Thanks,
Craig
Craig Futterman


Reply With Quote
  #2  
Old   
Anders Jonsson
 
Posts: n/a

Default Re: decimal places with numbers - 04-19-2007 , 01:30 PM







Quote:
In my code I have the following:
NuConcentration = TC.Concentration
If I view nuConcetration I see 0.03
That is because Paradox displays the number in a default format with only
two decimals when you use view.


Quote:
More importantly, when the math is done (numbers X numbers) it is as
if it 0.03.
Are you sure about that?

If you do

view(nuConcetration * 1000)

I think you should se 25.00


Quote:
Any suggestions?

Use the format command to display what you need and set the format of the
fields in you forms and report. You can create your custom formats if you
need to.

Anders





Reply With Quote
  #3  
Old   
Jim Moseley
 
Posts: n/a

Default Re: decimal places with numbers - 04-19-2007 , 04:16 PM




Jonathon,

In addition to Anders post, here's my 2 cents.

Make sure you have NuConcentration explicitly defined, as in:
var NuConcentration number endVar

or cast the value as:
NuConcentration = number(TC.Concentration)

HTH,
Jim Moseley

Reply With Quote
  #4  
Old   
Anders Jonsson
 
Posts: n/a

Default Re: decimal places with numbers - 04-19-2007 , 11:48 PM



Quote:
Make sure you have NuConcentration explicitly defined, as in:
var NuConcentration number endVar
Good point. I always do it myself but it's easy to forget if you have
compiler warnings off.



Anders





Reply With Quote
  #5  
Old   
Robert Wiltshire
 
Posts: n/a

Default Re: decimal places with numbers - 04-20-2007 , 01:11 PM




Sometimes I like the format command in this situation,
it helps you see precision of numbers.

To help see default behaviors,
consider the following code snippet:


var
nu number
st1,st2 string
endvar

nu = .025

st1 = string(nu)
st2 = format("W.4",nu)

nu.view("number")
st1.view("nu to string,no format")
st2.view("nu with format")


Robert Wiltshire





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.