From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB35A25F994 for ; Tue, 13 Jan 2026 03:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768275155; cv=none; b=PkqaG3MA6fo9nucyyF8MjQM8wgfrMVPfHkqp4j9FPw7CsVmPzyC8QlM4TJaX2S+wkYxBjl+wG+a4ujkyoiMHqsMmPlAQeqT5IABaUAh5KVV5ITlMt9tPb3jNI2m59esvOE7OGiK//ExzLNzlYd6zZhEIc18ypAZXb8TnaxpVjN0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768275155; c=relaxed/simple; bh=VBvnDLdfB6iwcfRLrlJ/kuNKTe4GcJzd0Rz2MGm7M04=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J7xhSP8iHTYDx9zEvqGb3wnfdc5S23xT8Sn9Ox7qID7YqCdWp4CDsBuc/Q/DOZuarvpen+94DQzwi/qyd/2bcVsslPuwrU9drzZ66tx/cqaJRq9wJBatnUybtEdyNI0k64B9VtvxPmaSLBtJVFgLe5rUtwL7SbktkOVY397GI4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cFI7UuR7; arc=none smtp.client-ip=209.85.160.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cFI7UuR7" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-4ee28771052so11553551cf.1 for ; Mon, 12 Jan 2026 19:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768275153; x=1768879953; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=oV5NIaorlKMCTvp26ZszHHcSIm+HDcOR72Vp7/q9+SY=; b=cFI7UuR7lRv47brkD0FFaMhFUHCkWsJjAAh+BbAMNDTigoAMpCW22c3LJrMPEIsXJq PglKf66Lc52ZEUDqLzl/Pc4Fqdi6j4I2SQn0pO1OXqEnC172hCPxdkG3pGlhJe/EZ8oN LqU7YYp0dRtV6NhahAzcjUGAXGguNPXdkKu56tyQT+98qAkLZKAUGEq0CfxYQMKfRkCe a4EB/014DWzbnjGveCJPyaHSFr0PjfXBu60o9zfOijQajeROTwiquMTSSDNN+vFX2sbI f90i6DnA+BQ9rZHv1/J6lK0yo0DSXsVGIcPkdcGNFwJy2WSKIxPGlKc4xr2FugXZN5uF G9oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768275153; x=1768879953; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oV5NIaorlKMCTvp26ZszHHcSIm+HDcOR72Vp7/q9+SY=; b=UXqHJz8DHinTY+Qir82HRKMi7XBB0l604tvy8bt1ea2P+D35JwaUmUOL59rYINQsC/ 3FmTcOKv+cn4mZ9VOEXmT0ylISM116X9CPvxZpWTjVAnSYlP1UTuw9vmjK3O7WNXHa90 68wSr9Sp44SIKDmNi/eGKgUksH987JJJwQQSfVXu+c2i5qzrlHxj16dN1gNw5yVSKOAe 1xTR+zbffUlihmluIhR/LPsZtmHVT/bTL78/vQbIpQP0TgY4sy4wy2RxyzJHbAz+Qdea rVyhiEMu0T08J+NfKeZKX5fn8TVCsFHOooGlfNi0q6IrvBfQf4b3NzMXY+4lLIc0EBA/ nzyw== X-Forwarded-Encrypted: i=1; AJvYcCWdLbg6zZxP4B8EAWtO2Xn0sDueZ30Wdi27aeV6IUODrfaSuYpkrjbxDkZauxEr1AJbwbBtED3Gcy8kG4Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzNWdkJIJmLHNyyhwwpIgeAhxwv9dmy20ynZWlCTJ9Pl9mM+6ul z1zDyfbwR0YcrWLfuMVO9bL3jc8PvJlmw6YJwmXS8lq9F3Bl6GIRcYgI X-Gm-Gg: AY/fxX4VAXrj4LnQsKQ6PYv/E6JaOoNNNnyxjmqLBcf4USPdTQ5pY/P9wkMQjOl6FSH 7fd5uy7rJt+LrStNjgQBp7M8LW63G23+LsKBrJxsvP5e2P2BWnsGpA6H1vyOZ0phxtdoAu6v7Um lgqrU4m243yMCvOr4OulpQNzoyxJiDXyByhqOID3+AxNVmnu77FDkv9N1MefkpGbBLTWiVvRQ5j y5JZYznmn+upXbaOsj7G+ki4BbD39MKfYLWe+s4bPmltKkUP/ljfaRJi9twk6Uyym3hNIyH0BZL ldaNYXtnr76w94VSEwERWon64RP8d0SHrCqgr7V9/JAmca0nZG73FziGKImHhn7L2yaikyKLgmi eNKwnBpFw9WV8ZmOggU0royw+4TVoUwpPPfhXrzJM5AaiMPt9q897EXv9fAWRSaYkVELIi/R8UV efbDSgvbJOmqkqI6reh/GKsFAscSb1it2+vheiE0g= X-Google-Smtp-Source: AGHT+IFUp5OFF4KEikizn6MysRARr9EShs8KxKd0mg/n83f3PKFKfM8PRx8cj6fUpU2eiwtqBDh5hA== X-Received: by 2002:a05:622a:211:b0:4ee:1367:8836 with SMTP id d75a77b69052e-4ffb48b6d14mr229624801cf.5.1768275152656; Mon, 12 Jan 2026 19:32:32 -0800 (PST) Received: from JSANTO12-L01.ad.analog.com ([179.146.84.3]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89077234ca1sm148878436d6.36.2026.01.12.19.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 19:32:32 -0800 (PST) Date: Sat, 10 Jan 2026 23:11:55 -0300 From: Jonathan Santos To: Andy Shevchenko Cc: Jonathan Cameron , Jonathan Santos , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lars@metafoo.de, Michael.Hennerich@analog.com, dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Subject: Re: [PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros Message-ID: References: <43504217d5b3c32da946bed0ce4d81e216f7c7c7.1765900411.git.Jonathan.Santos@analog.com> <20251227155525.6d712f42@jic23-huawei> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On 12/27, Andy Shevchenko wrote: > On Sat, Dec 27, 2025 at 5:55 PM Jonathan Cameron wrote: > > On Wed, 17 Dec 2025 02:52:45 -0300 > > Jonathan Santos wrote: > > ... > > > > +/* > > > + * Percentage and basis point units > > > + * > > > + * Basis points are 1/100th of a percent (1/100), commonly used in finance, > > > + * engineering or other applications that require precise percentage > > > + * calculations. > > > + * > > > + * Examples: > > > + * 100% = 10000 basis points = BASIS_POINTS > > > + * 1% = 100 basis points = PERCENT > > > > I don't understand the final equality in these examples. > > The top line is as it says 10000 basis points but you have it equal > > to BASIS_POINTS? > > Also there are pp (percentage points) and others like per mille > > https://en.wikipedia.org/wiki/Percentage_point (see "Related units" section). > Hi, Andy. Thanks for the suggestions,but I am still questioning how the percentage points would be implemented, since it is defined as the difference between two percentages and we cannot use floating points. Also, should we keep this approach of unit conversion? Example: value / PERCENT -> converts a value from percent to ratio value * PERCENT -> converts a value from ratio to percent Just to make sure it is consistent with the rest. > > > + */ > > > +#define PERCENT 100UL > > > +#define BASIS_POINTS 10000UL > > > -- > With Best Regards, > Andy Shevchenko