From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id C724E17D80CE for ; Fri, 10 Jul 2015 07:45:25 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 1DCAAB5D8EA for ; Fri, 10 Jul 2015 08:12:48 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id E9E4997A836 for ; Fri, 10 Jul 2015 08:12:48 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UPSfAp870JuK for ; Fri, 10 Jul 2015 08:12:48 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 5577F97A827 for ; Fri, 10 Jul 2015 08:12:48 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 5F46A95243E for ; Fri, 10 Jul 2015 08:12:47 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 82A64120475; Fri, 10 Jul 2015 08:12:45 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 4A7CC1203F8 for ; Fri, 10 Jul 2015 08:12:41 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=PpO/QDTGSBAZUQtYpbkgbOKk2m8=; b=ZZhzM1hMMwK6cxlsfR FB8TnLVnK0F7jm1jx5dQ9xNZK4kN8loX4fzzUk/mXCLmOFipYMhU0zOYKP3QXrx2 u4vb8xyeI43dmNQ1jQ+XEUjm83LyRCpSGRqDSRiaos5g4RRn2hpH39HauZD0Td3n 3Qbjlr46WBZC9J1ybdCjHwVeQ= Received: by filter0568p1mdw1.sendgrid.net with SMTP id filter0568p1mdw1.13920.559EFFE31E 2015-07-09 23:12:36.21740566 +0000 UTC Received: from herokuapp.com (ec2-54-161-150-57.compute-1.amazonaws.com [54.161.150.57]) by ismtpd-048 (SG) with ESMTP id 14e751792d8.1f36.9ffffd Thu, 09 Jul 2015 23:12:36 +0000 (UTC) Date: Thu, 09 Jul 2015 23:12:35 +0000 From: 0x0dea+redmine@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 44537 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10594 X-Redmine-Issue-Author: findchris X-Redmine-Sender: 0x0dea X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6gVnqEvfOJi+sTAtG2QM7FkQ3aPith9tuMyC EVkqxqV7nFRws7j56XuFHf69POuJ2kQfHOncV4sj1Tsu5562gYUETFDmkNSPxnIeT2QKS/oRA+6ww6 hfuHottdN6U1Y4/F7vaWcW6/McUJmdmopVCQ X-SendGrid-Contentd-ID: {"test_id":"1436483557"} X-ML-Name: ruby-core X-Mail-Count: 69924 Subject: [ruby-core:69924] [Ruby trunk - Feature #10594] Numeric#clamp X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #10594 has been updated by D.E. Akers. Ferdinand Niedermann wrote: > Here you go: https://github.com/ruby/ruby/pull/962 The failure condition should be `min > max` rather than `max < min`. It's arguably rather silly to clamp to a single value, but the operation is nevertheless well-defined, and it would therefore be an error for `#clamp` to raise given equal `min` and `max`. ---------------------------------------- Feature #10594: Numeric#clamp https://bugs.ruby-lang.org/issues/10594#change-53347 * Author: Chris Johnson * Status: Open * Priority: Normal * Assignee: ---------------------------------------- This is basically a re-opening of the feature request of issue#4573 (https://bugs.ruby-lang.org/issues/4574), which was closed due a naming debate. It seems the standard naming for restricting a number to a specified range is indeed 'clamp'. (1)(2)(3) As such, can we use Yusuke Endoh's original patch with the naming adjustments? If so, I can provide accordingly. Cheers. (1) http://www.rubydoc.info/github/epitron/epitools/Numeric:clamp (2) http://stackoverflow.com/questions/12020787/is-there-a-limit-clamp-function-in-ruby (3) https://developer.gnome.org/glib/stable/glib-Standard-Macros.html#CLAMP:CAPS ---Files-------------------------------- num_clamp.c (427 Bytes) -- https://bugs.ruby-lang.org/