czardas Posted September 19, 2015 Share Posted September 19, 2015 (edited) I have been thinking about what constitutes an error in basic mathematical operations. I'm beginning to form the opinion that very few exist. Division by zero is not really an error - or is it? Just because we can't represent certain numbers in binary doesn't imply an error. What about imaginary roots? - they have properties but we call them NaN. I'm curious about your opinions in relation to programming. Do you consider -1^0.5 to be an error?EditTo clarify: normally we catch these events before a they happen and return an error from the function we are writing. This has to be done this way because no error is thrown by the mathematical operation itself. Context is of consequence here. Edited September 19, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
orbs Posted September 19, 2015 Share Posted September 19, 2015 (edited) i can't help but recall that _FileListToArray() returns an error when no files found - which is a perfectly valid result. i'd presume error definition varies quite widely, in any discipline you look at. in general, i would say that an error should be defined as a situation which prevented you (or your script, or your mathematical operator) from performing its task. as far as math is concerned, being the most abstract of all exact sciences, i'd recon one would have to work pretty hard to formulate such circumstances, if possible at all. for your example, -1^0.5, although hardly useful, may well be a perfectly valid result, in some unforeseen scenario. let's look at the other approach: say i currently cannot imagine such a scenario, therefore i define it as an error - that would be quite arrogant on my part; and when such scenario does come to existence, would i say "oh, the error was resolved."? ridiculous. and as for programming - one should sanitize input before processing, so if an error does occur, it is most likely a "real" error, not just feeding gibberish to functions. Edited September 19, 2015 by orbs czardas 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
jchd Posted September 19, 2015 Share Posted September 19, 2015 Taking the sqare root of -1 ( i ) is only an error when the operation takes place outside of the suitable set within a given math "theory" (a set of axioms), for instance the set of so-called complex numbers, namely ℂ.As you say, everything is context-dependant. Yet there are rules that needs to be observed in every math context, like predicate logic, because they are the funding of the mathematical thinking. If you create new fundamental rules (i.e. a new axiomatic), then you're building another distinct math construct (theory) with which you're left alone.When doing mathematical operations with a computer, things are a little more fuzzy, because you're always limited by implementation possibilities. That may be by limited integer or real (FP) representation, by the difficulty to implement abstract entities or by the time operations require. As a basic example of such difficulty, there is no good way to perform actual computations with the real counterpart of the rational ⅓ which is normaly noted 0.3 with a black dot above the 3. Even an unlimited precision arithmetic library can't represent it (it can represent unbounded precision but not infinite precision).So an error in computer context is nothing more than hitting one limitation of the hardware or software you use even if you stay within a sound mathematical theory (don't violate the set of rules of the underlying axiomatic). czardas 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
czardas Posted September 19, 2015 Author Share Posted September 19, 2015 (edited) Both responses are very helpful to me, although I'm still unsure if these types of result should be considered errors in coding generally. The examples I gave do not crash AutoIt, and return a numeric value - albeit one which is generally meaningless in most programming contexts. I was thinking of having error codes consistent with all functions in a particular UDF - which could involve gaps eg. @error = 1, 2, ... 5. Then I was thinking of doing the same with @extended information, and infinity (or i) would set the extended flag instead. Then if someone wanted to use these values, they could do so without errors being returned by the UDF functions. This seems to be the way things are done already - with the onus still being on the user to catch problems themselves before they occur (when a mathematical operation occurs). Edited September 19, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted September 27, 2015 Author Share Posted September 27, 2015 I decided to try this approach: https://www.autoitscript.com/forum/topic/176620-operator64/?do=findComment&comment=1274843 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now