function to leave fractional (decimal) part

  • Thread starter Thread starter annfos
  • Start date Start date
A

annfos

I need a way to "truncate" a number by removing integer part and
leaving decimal. Something opposite to function TRUNC. I hope someone
helps me.
 
Maybe:

=a1-int(A1)
or
=mod(a1,1)



I need a way to "truncate" a number by removing integer part and
leaving decimal. Something opposite to function TRUNC. I hope someone
helps me.
 
Oh!! I still can't do what I want! here's what happens now:
=if(mod(A1;1)=0.05;.... doesn't return TRUE when it's actually true!
 
It could be a rounding error -- or it could be that the actual value in A1 isn't
what you see (hidden by formatting (two decimals maybe????).

You could look for a little rounding error with something like:

=if(ABS(MOD(A1,1)-0.05)<0.0000000001,"close enough","not too close")

Change that 0.0000000001 to as close as you need.
 
Try =IF(A1=INT(A1)+0.05;...) to minimize binary/decimal conversion issues.

Most exact decimal fractions (including 0.05) have no exact binary
representation and hence must be approximated (just as 1/3 must be
approximated in decimal. To illustrate, think of a hypothetical
calculator that carries 4 decimal figures, then 4/3 would be 1.333 and
1/3 would be 0.3333. Your calculation would then be like
IF((1.333-1)=0.3333;...) = IF(0.333=0.3333;...)
which correctly identifies a difference.

Jerry
 

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

Back
Top