help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: length of an integer


From: c.
Subject: Re: length of an integer
Date: Fri, 3 May 2013 15:02:01 +0200

Hi,

Please keep the list in BCC as others might also be interested and add your 
answer at the end of the message
to help follow the discussion.

On 3 May 2013, at 14:13, André MICHEL <address@hidden> wrote:

> Le 29/04/2013 22:00, c. a écrit :
>> On 29 Apr 2013, at 00:33, André MICHEL <address@hidden> wrote:
>> 
>>> How do I get the integer part of a basic arithmetic division of integers? 
>>> (next sup and/or next inf)
>> http://www.gnu.org/software/octave/doc/interpreter/Utility-Functions.html#doc-mod
>> 
>> HTH,
>> c.
>> 

> Good afternoon again
> Do you know how to code the length (number of digits) of a given integer 
> without trying the division by successive powers of 10?
> Yours
> André

there may be more clever approaches but the following does work:

>> count_digits = @(x) floor (log10 (x)) + 1;
>> count_digits (999)
ans =  3

c.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]