Problems with Round and Trunc

Problems with Round and Trunc

Post by Peter Reb » Thu, 21 Nov 1996 04:00:00

> >I assume you are talking of Paradox 7 and D2 which I haven't used yet.
> >When I use the DBD and look at a Currency type field in my Paradox 5 table,
> >I see e.g. a value 0.43<Symbol>. Then I press the Field Edit Button -- and what
> >do I get? 0.429999999999836! Does not look like an integer value to me.

> I don't see how this tells you anything.  It could be that the field
> editor has a bug, and doesn't convert the strings properly, or you're
> asking to view the field in an inappropriate format.  

Are you for real? Do you use the stuff and work with it?
1) A field editor that converts an integer value to the one given
above would have a serious bug indeed!
2) The DBD does not allow me to chose the display format, but selects
it from the definition given when the table was created.

Quote:> To figure out what the storage format is, you should read the
> documentation (i.e. the Object Pascal Language Guide for Delphi)

What I am talking about has nothing to do with Pascal or Delphi per se.
I am talking about how the data is stored in a Paradox 5 table. It is of no
use to have Delphi calculate the values in integer format when they
are converted to floating point format for table storage. Using the Comp data
type, or the new D2 Currency type, is therefore of no use.
Speaking of that, I know that the value which was passed to the table
was _exactly_ 0.43, rounded and viewed with the de*.

All the following refers to manuals shipped with D1. Check in the
Database Application Developer's Guide, page 86, about TField conversion
    TFieldType      AsFloat
    TCurrencyField  Float type by definition

Local Interbase User's Guide, page 185, Paradox to BDE Logical to dBASE
Data Type Translations
    Paradox Physical    BDE Logical           dBASE
    fldPDXMONEY         fldFLOAT/fldstMONEY   fldDBFLOAT{20.4}

page 186, dBASE to BDE Logical to Paradox Data Type Translation says
    dBASE Physical      BDE Logical           Paradox
    fldDBFLOAT          fldFLOAT              fldPDXNUM

Neither does using INTERBASE help, it only knows integers (32 bits max)
and single and double precision formats. See Interbase Data Definition Guide,
page 50ff. Yes, I printed the whole manual AND read it too.

The followings is a direct extract from the BDE.INT file of the
Delphi 2 Developer CD-ROM

//begin extract
{ Field Types (Logical) }

  fldUNKNOWN         = 0;
  fldZSTRING         = 1;               { Null terminated string }
  fldDATE            = 2;               { Date     (32 bit) }
  fldBLOB            = 3;               { Blob }
  fldBOOL            = 4;               { Boolean  (16 bit) }
  fldINT16           = 5;               { 16 bit signed number }
  fldINT32           = 6;               { 32 bit signed number }
  fldFLOAT           = 7;               { 64 bit floating point }
  fldBCD             = 8;               { BCD }
  fldBYTES           = 9;               { Fixed number of bytes }
  fldTIME            = 10;              { Time        (32 bit) }
  fldTIMESTAMP       = 11;              { Time-stamp  (64 bit) }
  fldUINT16          = 12;              { Unsigned 16 bit integer }
  fldUINT32          = 13;              { Unsigned 32 bit integer }
  fldFLOATIEEE       = 14;              { 80-bit IEEE float }
  fldVARBYTES        = 15;              { Length prefixed var bytes }
  fldLOCKINFO        = 16;              { Look for LOCKINFO typedef }

  MAXLOGFLDTYPES     = 17;              { Number of logical fieldtypes }

{ Sub Types (Logical) }

{ fldFLOAT subtype }

  fldstMONEY         = 21;              { Money }

//end extract

IMO you are talking rubbish. BTW, why is this a private discussion
from your side? I would think that the problem of rounding and especially
the handling of currency values would be a matter of great general
interest and thus belongs into the ng.

Peter Reber


1. Trans Log- to trunc or not to trunc

OK, MS books online really doesn't do a good job at explaining this so I
thought I might find somebody who does.

The Objective: To be able to restore the database to a point of time on my
SQL2000 box and also make sure that my trans log does not fill up the hard
drive. My db is set to full recovery. I am doing a full backup at 8:00 PM
then transactional backups every two hours with "Remove Inactive Entries
From Transaction Log" cleared. At 7:30 PM I am doing my last transactional
and telling it to Remove Inactive Entries From Transaction Log in order to
truncate it to keep it from growing.

1.)When you do a database backup, does it by default truncate the
transaction log? One strategy I saw was to do a database backup and then 5
mins later do a trans log backup. Is this the right way? The default on a DB
backup is to Remove Inactive Entries From Transaction Log. If that is the
case then there would only be 5 mins worth of transactions since the DB
backup truncated the log file 5 mins before. What am I mising here?

2.) When you do a trans backup just specifying what log file and to where,
is the log file automatically truncated thus freeing up room?

3.) Should I uncheck the box that says Remove Inactive Entries From
Transaction Log when doing my full backup?

Any pointers to something that does a GOOD CLEAR job of explaining this
would be great. All help is appreciated.



2. Language problem

3. trunc() problem 0.01999999 or 0.02 ?

4. Oracle 8i triggers trouble: please help

5. Char trunc problems with SqlServer7

6. where can i download progress for linux

7. Trunc. log on checkpoint problem

8. Executing MDX with VBA function through VB

9. Round 0.5 is rounded down instead of UP!!!

10. ROUND not accurating rounding/truncating

11. Round-and-round with passwords

12. Round 0.5 is rounded down instead of UP!!!

13. URGENT:SQL-server/Access mysterious number rounding problem