Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Truncation function
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Shadow Raider  
View profile  
 More options Jan 8, 6:50 am
From: Shadow Raider <angeran...@gmail.com>
Date: Thu, 8 Jan 2009 03:50:49 -0800 (PST)
Local: Thurs, Jan 8 2009 6:50 am
Subject: Truncation function
Hello everybody,
do you know if it exists a function for correct number truncation?
Examples:

a:  5.44321
a: trunc 2  a
print a
== 5.44

b: 5.44621
b: trunc 2 b
print b
== 5.45

b: 5.44621
b: trunc 3 b
print b
== 55.446


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sqlab  
View profile  
 More options Jan 8, 8:09 am
From: sqlab <sq...@gmx.net>
Date: Thu, 08 Jan 2009 14:09:03 +0100
Local: Thurs, Jan 8 2009 8:09 am
Subject: Re: [REBOL-GG] Truncation function
round can deliver that

 >> help round
USAGE:
    ROUND n /even /down /half-down /floor /ceiling /half-ceiling /to scale

DESCRIPTION:
     Returns the nearest integer. Halves round up (away from zero) by
default.
     ROUND is a function value.

ARGUMENTS:
     n -- The value to round (Type: number money time)

REFINEMENTS:
     /even -- Halves round toward even results
     /down -- Round toward zero, ignoring discarded digits. (truncate)
     /half-down -- Halves round toward zero
     /floor -- Round in negative direction
     /ceiling -- Round in positive direction
     /half-ceiling -- Halves round in positive direction
     /to -- Return the nearest multiple of the scale parameter
         scale -- Must be a non-zero value (Type: number money time)

 >> round/to/even a 0.01
== 5.44

 round/to b 0.01
== 5.45

 >> round/to/even b 0.001
== 5.446


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shadow Raider  
View profile  
 More options Jan 8, 12:43 pm
From: Shadow Raider <angeran...@gmail.com>
Date: Thu, 8 Jan 2009 09:43:57 -0800 (PST)
Local: Thurs, Jan 8 2009 12:43 pm
Subject: Re: Truncation function
On 8 Gen, 14:09, sqlab <sq...@gmx.net> wrote:

It works! Great!!!
Thank you very much!
Max

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shadow Raider  
View profile  
 More options Jan 12, 4:23 am
From: Shadow Raider <angeran...@gmail.com>
Date: Mon, 12 Jan 2009 01:23:03 -0800 (PST)
Local: Mon, Jan 12 2009 4:23 am
Subject: Re: Truncation function
On 8 Gen, 14:09, sqlab <sq...@gmx.net> wrote:

It seems to work with only  "round/to".
Max

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gregg Irwin  
View profile  
 More options Jan 12, 10:37 am
From: Gregg Irwin <gregg.ir...@gmail.com>
Date: Mon, 12 Jan 2009 08:37:13 -0700
Local: Mon, Jan 12 2009 10:37 am
Subject: Re: [REBOL-GG] Re: Truncation function
Hi Max,

SR> It seems to work with only  "round/to".

ROUND/DOWN is the equivalent of truncate in other languages. That will
round to the nearest integer.

--Gregg


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google