Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
testing a number's quare root is an integer and casting to a value?
#10
(01-27-2025, 09:56 PM)Jack Wrote:
Quote:testing a number's quare root is an integer and casting to a value? 
@madscijr
the question is a bit fuzzy to me, I thought you were asking whether a given square-root of a number was an integer
I haven't tested whether  the sqr function gives exact square-roots of numbers which square-root is an integer
Yeah, I wanted to find if a number's square root was a straight integer, and thought casting it to an int (or long, just a non-floating point number really), I could then compare it to the actual square root, and see if they're equal. I hadn't tried cast in qb64pe yet but that could be useful for a lot of stuff.

(01-27-2025, 09:15 PM)Pete Wrote: Just don't ever get caught by variable type precision limits...

num = 5542534534534534534534532453453454534534.5 ' Number too big for variable type.
Print InStr(Str$(num), ".") ' Fails.
If num = Int(num) Then Print "Integer" 'Fails

Pete
Ha! Yeah, this isn't for really big numbers, integer is good.
Reply


Messages In This Thread
RE: testing a number's quare root is an integer and casting to a value? - by madscijr - 01-28-2025, 01:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Maximum Number of Attachments per Thread Magdha 7 468 01-13-2026, 10:13 AM
Last Post: Magdha
  getting the number of dimensions in an array on the fly? madscijr 7 745 09-16-2025, 12:34 AM
Last Post: madscijr
  Random Number Generator pmackay 14 1,274 07-30-2025, 12:56 PM
Last Post: SMcNeill
  Illegal string-number conversion Herve 7 774 07-07-2025, 09:53 AM
Last Post: a740g
  Why are SINGLE variables faster than INTEGER variables ? Elzaimer 18 2,372 07-07-2025, 05:01 AM
Last Post: ahenry3068

Forum Jump:


Users browsing this thread: 1 Guest(s)