palindrome with numbers - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7) +---- Thread: palindrome with numbers (/showthread.php?tid=786) |
palindrome with numbers - madscijr - 08-19-2022 Here's a neat little math factoid a coworker shared with us, if you multiply 111,111,111 times 111,111,111 the answer is 12345678987654321 (reads the same backwards as forwards). I got it working in QB64 with _INTEGER64, but a plain Excel formula does not yield the right answer! Code: (Select All) Dim n1&&, n2&&, n3&&, n4&& RE: palindrome with numbers - SMcNeill - 08-19-2022 Looks like Excel is probably converting to a DOUBLE type variable for the answer. https://docs.microsoft.com/en-us/office/client-developer/excel/data-types-used-by-excel -- from the online documentation, there's no INT64 type support. Since the result is larger than a LONG can hold, it's given as a DOUBLE, which loses precision after swapping into scientific notation. RE: palindrome with numbers - madscijr - 08-19-2022 (08-19-2022, 03:57 PM)SMcNeill Wrote: Looks like Excel is probably converting to a DOUBLE type variable for the answer. Wow, I remember when Excel 2007 came out and everything started going to 64-bit, and we got a million rows and each cell could hold more than 255 characters. Sounds like they're due for another upgrade! (I'm still a huge fan of Excel and VBA, which along with QB64 is my go-to programming and utility platform ... It would be super cool to see a spreadsheet app in QB64!) RE: palindrome with numbers - Kernelpanic - 08-19-2022 I have a problem! It doesn't work at all with "111.111.111" (without points of course), but it gets interesting with 111.111: It is displayed correctly in VisualBasic 5.0, but not in QB64. It doesn't matter if it's "Double", "_Integer64" or "_Unsigned _Integer64", the result is wrong. Did I make a mistake there, or is that a bug? RE: palindrome with numbers - SMcNeill - 08-19-2022 (08-19-2022, 08:46 PM)Kernelpanic Wrote: I have a problem! It doesn't work at all with "111.111.111" (without points of course), but it gets interesting with 111.111: It is displayed correctly in VisualBasic 5.0, but not in QB64. Change it to: DIM AS _INTEGER64 var1, var2, var3 (whatever the variable names were) I refer you back to here: https://qb64phoenix.com/forum/showthread.php?tid=279 RE: palindrome with numbers - Kernelpanic - 08-19-2022 Quote:Change it to: OK, now it works with 111.111.111 too. Thanks! --- Yes, this is like in C. Basic goes to C. PS: These are tips that belong in a book about QB64. RE: palindrome with numbers - SMcNeill - 08-19-2022 (08-19-2022, 09:27 PM)Kernelpanic Wrote:Quote:Change it to: Or maybe even in a wiki article: https://qb64phoenix.com/qb64wiki/index.php/DIM RE: palindrome with numbers - Kernelpanic - 08-19-2022 The Wiki is great! Really! But people like I need a book. A Wiki is a addition, but without book . . . |