• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Semi-OT] Using just the decimal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Semi-OT] Using just the decimal


  • Subject: Re: [Semi-OT] Using just the decimal
  • From: "John C. Randolph" <email@hidden>
  • Date: Mon, 3 Sep 2001 04:40:07 -0700

On Monday, September 3, 2001, at 03:33 AM, Rob Rix wrote:

Sorry, but not only can I not remember what function does this, but I also can't find my book on C, so I'm forced to resort to the list.

What function (in math.h or wherever else) removes the whole value from a double?

So, given 3.1415, this function returns 0.1415, given 3.0, it returns 0.0,
et cetera. Sort of like the opposite of rounding. I can't remember the actual term for this, either...

I don't know of any such function, but I'd do it like so:

double someNumber;

double fractionalPart = someNumber - floor(someNumber);

or

someNumber -= floor(someNumber);

FLOOR(3) System Programmer's Manual FLOOR(3)

NAME
floor - round to largest integral value not greater than x

SYNOPSIS
#include <math.h>

double
floor(double x)

float
floorf(float x)

DESCRIPTION
The floor() and floorf() functions return the largest integral value less
than or equal to x.

SEE ALSO
abs(3), ceil(3), fabs(3), ieee(3), rint(3), math(3)

STANDARDS
The floor() function conforms to ANSI C3.159-1989 (``ANSI C'').

BSD Experimental March 10, 1994 1

-jcr

"Only in a police state is the job of a policeman easy." - Orson Welles


References: 
 >[Semi-OT] Using just the decimal (From: Rob Rix <email@hidden>)

  • Prev by Date: RE: [Semi-OT] Using just the decimal
  • Next by Date: Re: [Semi-OT] Using just the decimal
  • Previous by thread: [Semi-OT] Using just the decimal
  • Next by thread: Re: [Semi-OT] Using just the decimal just use modf()
  • Index(es):
    • Date
    • Thread