Re: TRUNC Function

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dani (anonymous_at_discussions.microsoft.com)
Date: 02/18/04


Date: Wed, 18 Feb 2004 11:07:02 -0800

Alright, the problem I have is that I have a series of
numbers as below:

115.18333
95.00000
129.81667
130.60000
110.49444
138.90556

These are angles in decimal degrees. I want to transform
them into degrees minutes and seconds (i.e truncate the
value before the decimal as degrees, multiply the
remaining decimal by 60, truncate that as minutes and
multiply the remainder by 60 for seconds). It truncates
the first part fine but when I try to truncate the minutes
(after multiplication), the first one comes up as 10
instead of 11 (I know it should be 11) unless I increase
the precision of the truncate function. But if I do that
then the 5th one rounds to 30 instead of 29. I need it to
work consistently. This is the answers I should be
getting and do using a calculator:

115 11 0
95 0 0
129 49 0
130 36 0
110 29 40
138 54 20

I have tested it using a calculator and I can see how it
would truncate to 10 (on the first one) if the number is
not held to its full precision in the calculator memory.
That is why I suspect it is a precision issue.

>-----Original Message-----
>Can you give an example?
>I only know that it rounds up when the value is negative
>
>--
>
>Regards,
>
>Peo Sjoblom
>
>
>"Dani" <anonymous@discussions.microsoft.com> wrote in
message
>news:125df01c3f64e$c5c91ec0$a001280a@phx.gbl...
>> I find that when I use the truncate function in Excel,
it
>> sometime rounds the data up, sometimes not. In the true
>> sense it should never round the number. I suspect it
has
>> something to do with the precision of the stored number.
>> I know I can reduce the precision of the stord data but
I
>> was wondering if there was anyway of increasing it?
>
>
>.
>



Relevant Pages

  • Re: TRUNC Function
    ... significant figures in you input data ... >them into degrees minutes and seconds (i.e truncate the ... >I have tested it using a calculator and I can see how it ... >not held to its full precision in the calculator memory. ...
    (microsoft.public.excel.misc)
  • Re: TRUNC Function
    ... I want to transform ... >them into degrees minutes and seconds (i.e truncate the ... >I have tested it using a calculator and I can see how it ... >not held to its full precision in the calculator memory. ...
    (microsoft.public.excel.misc)
  • Re: MicroBlaze floating point precision issues
    ... implementation is presenting *supposedly* single-precision floating ... precision is 0x4036000000000000. ... So, truncate the double-precision ... cycles doing wasteful double to float conversions. ...
    (comp.arch.fpga)
  • Re: Weird problem on Lahey lf95 v6.2b
    ... >>print statement, but in the second and third has been truncated down ... > of register usage - enough to flush most anything. ... use of extended precision for intermediate results, ... The x87 processor has the ability to truncate the fraction ...
    (comp.lang.fortran)
  • Re: Modulus and negative operands
    ... >>If / rounds to zero, ... The benefit of "truncate toward zero" on division are ... Quotient and remainder are governed by the identity ...
    (comp.lang.c)