Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Vivek Patel   on Aug 03 In Asp.net Category.

  
Question Answered By: Aalia Arain   on Aug 03

function  that
will return true if there are no decimal points and false if there
are.

Maybe a little futher explanation would help. I'm trying to
determine if give number  is a power of 2. The math  function log
does this very nicely, but the determination is wheather or not the
function returns an integer or not. For instance:

Log(4,2) = 2 which means that 4 is a power of 2
Log(5,2) = 2.3219... which means that 5 is not a poewr of 2

I originally converted the result to a string  and then checked to
see if a decimal point existed using the indexOf method, but I
didn't like it as I felt the data conversion and searching through a
string might cause a bit of a performance hit.

What I was _REALLY_ hoping to get was a math function, but the
answer Scott provided is sufficient.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Math function to determine if a number is an int Or get search suggestion and latest updates.


Tagged: