0

I want to express in one word whether a number has a remainder or not.

as an example:

  • 3.5 is not remainderless

  • 3 is remainderless

It might seem that something like "3 is whole" or "3 is an integer" fits better but it is important that remainders, floating points or decimals are directly adressed.


Why I require this: I have a scenario where I want to express in a C++ function whether

log_a b

yields an integer or a decimal. This is constant compile time arithmetic which I have implemented to solely work with integers - so actually asking if an result "is an integer" is superfluous as every result is always an integer.

The intent for this function is to stand out by actually talking about floating points. Since this is impossible to execute it behaves on a more hypothetical level as in saying: "would the result log(a, b), hypothetically, have a remainder".

As for a function that stands out in an "integer saturated environment" I find it to be a necessity to include unorthodox, contrastive wording - like remainderless.


Which made me wonder is there is a better, mathematical adequate synonym for remainderless while still talking about decimals.

9
  • The mathematical term for any number not an integer is 'non-integral', better used as a noun [modifier] 'non-integer'. How you then convert the initial number to another (integer) number (eg 3.14159 becomes 3142) is immaterial; 3.14159 remains a non-integer. // One could call non-integers 'numbers having a non-zero decimal part', but why bother? – Edwin Ashworth Jul 1 '19 at 13:54
  • You're not looking for 'mantissa' are you? It's a special name for 'the decimal part of a number but only when that number is the evaluated logarithm, to a specified base, of an original number'. Eg, with log123 = 2.08990 (truncated), the mantissa is 0.0899 (4dp). It is a term rarely used for numbers in general (ie when not 'using logs'; the term was useful when logs were commonly used for numerical calculations in say schools. – Edwin Ashworth Jul 1 '19 at 14:24
  • So basically you're looking for a word meaning exponential in base (probably not understood without context). Basically, you're asking what is to logarithm what cube is to the cube root? – JJJ Jul 1 '19 at 14:25
  • @JJJ I yes you are correct. So when talking exponentiation, exponentiation_of_a_fits_b seems like a decent workaround. The Problem is that it doesn't adress log and that could be problematic. – Stack Danny Jul 1 '19 at 14:28
  • 1
    @EdwinAshworth I would have to go for mantissaless then, which is correct but seems worse than remainderless. – Stack Danny Jul 1 '19 at 14:29
3

The notion of a remainder is associated with division -- it's what remains after subtracting the divisor as many times as possible. Note that the remainder is not the fraction part of the result. The remainder in 25/10 is 5, and the remainder in 20/8 is 4, even though those operations produce the same result.

There is no notion of a "remainder" associated with the logarithm.

I think you want to say that when b is a power of a, then your function produces an exact result.

2
  • 1
    Absolutely right, I'd got sucked into thinking of 'remainder' as being the same as 'non-integer part' which, of course, it isn't. On reflection I think that the OP's best naming option is log_a_b_is_integer(a,b). That says it all and implies a boolean return, the base a log of b is either an integer, has a non-integer part or is undefined. If it's undefined it isn't an integer any more than the result of 1/0 is an integer. – BoldBen Jul 2 '19 at 4:39
  • This is correct. My implementation will probably be that log(a, b) returns a proxy state so I can write: can_be_representable_as_integer(log(a, b)); or yields_exact_integer_value(log(a, b));. Since this is compile time evaluation I do not have to worry about performance as all of this gets inlined and disappears before runtime. Thanks to you Matt. And @BoldBen for correctly identifying the matter and expanding upon it. – Stack Danny Jul 2 '19 at 7:27
1

I guess what you're looking for is a variable or function called something like IsRemainderless, which would be true when there is no remainder. Well, that's certainly a mouthful. But isn't this the exact opposite of "HasRemainder"?

So, this is my proposal:

HasRemainder

It is up to you to self-document the program so that the reader and the maintainer understand how you've set this up.

If this is unacceptable for some reason, then you could go with

NoRemainder

which is a more succinct version of

HasNoRemainder

-2

Programmers and computer scientists call the action of coercing a floating-point or double to an integer truncation. The verb is to truncate.

trunc

Truncate value

Rounds x toward zero, returning the nearest integral value that is not larger in magnitude than x.

C++ reference

Perhaps your C++ function could be a Boolean called isTruncated.

EDIT: Mathematics Mathematicians call the function that returns the largest integer less than or equal to a number with or without decimals floor.

In mathematics and computer science, the floor function is the function that takes as input a real number x and gives as output the greatest integer less than or equal to x...

Wikipedia: Floor and ceiling functions

The word floored means overwhelmed in most contexts. However, in your computer programming context, you might consider floored (as an alternative to remainderless or mantiassalessness).

3
  • +1 from me, I didn't consider that and it fits the IT jargon. – Stack Danny Jul 1 '19 at 14:46
  • Thank you for the +1. While I'm scratching my head over the downvote, I'm editing to add a mathematical context. – rajah9 Jul 1 '19 at 14:53
  • 1
    @rajah9 I didn't do the downvote but I don't believe that truncate expresses what StackDenny is thinking of at all. In a comment StackDenny gives the example log_a_b_remainderless(5,25) returns TRUE since the base 5 log of 25 is 2. This is true because it returns an integer. However log_a_b_remainderless(4,25) would return FALSE since 25 is not a power of 4. If you truncated log_a_b(4,25) you would get 2 but only log_a_b(4,16) would return 2 as an integer. I don't believe that truncate works at all. – BoldBen Jul 2 '19 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.