Log in

View Full Version : 2 beginner questions


ozen
01-09-2003, 10:35 PM
hey I have a couple of question the first one is what kind of programming language do the (High-end) calculators, like scientific calculators because the can usually go further without any round off error?. The second question is how does a programming language discribe time like go here after 5 seconds then go her after 30 seconds?
Any help???

Bearjaw
01-09-2003, 10:53 PM
Way above my paygrade, but I'm sure someone can help you here. My brain hurts just from reading the question. LOL Jeff

dMores
01-09-2003, 10:58 PM
uhm, well you need to be a little more specific.

"a scientific calculator" does not "exist". There's sharp, texas instruments, hewlett packard etc.
of course they need to round numbers, since 1/3 for example does not return a finite number. i only know from my hewlett packard hp48 that it uses more decimal digits than it displays. so the round-off-error is "not visible".

"programming language": we need to know what language YOU are programming in.
if you want an HTML page to automatically go to another page after X seconds, you need to add a meta tag to the html header.
or do you use visual basic, or turbo pascal :) or c++ or c# ?

just like human languages, programming languages have their own "vocabulary". so it's impossible to say what you need to use to get the result you wish.

ozen
01-09-2003, 11:34 PM
I mean some calculators can go up to ex 12 digits(im not sure) when something like an int in C++ goes up to X amount of numbers then has round off error. I want to know what kind of language are they using to go up to higher digits or does it just work the round off error into the anwser without tell you? Im not sure how clear this is but im not really a full-steam programer so im not to sure if what im saying is even making sense. And the time thing i'll just post that in a different post.

Kati Compton
01-10-2003, 12:44 AM
I mean some calculators can go up to ex 12 digits(im not sure) when something like an int in C++ goes up to X amount of numbers then has round off error. I want to know what kind of language are they using to go up to higher digits or does it just work the round off error into the anwser without tell you? Im not sure how clear this is but im not really a full-steam programer so im not to sure if what im saying is even making sense. And the time thing i'll just post that in a different post.

If you want a bigger int in C++ you can always define a class to emulate a larger bitwidth integer. You could have 512-bit integer mult/add/sub etc. if you wanted. Same for floating point. If you need capabilities beyond what's provided with base datatypes, you can simulate it in just about any language (can't think of any you can't). It's MUCH cleaner in OOP of course.

garrans
01-10-2003, 01:13 AM
There are many ways around built in roundoffs. Detailed programming books can lead you in this direction. These methods are what have been used to calculate pi (3.1415.....) to many decimal places. If you pick up a book on Microcontroller programming they generally have details in there as you often have to multiply many numbers with only 1 byte fields.

With programming for .NET there are predefined types that have certain characteristics. I can't remember what the .NET defintion is but normally you have DOUBLE (2 byte) Floating point etc. Think of it more as how many significant digits you are using. ie: 121.056 has 6 significant digits, whereas 0.00134786 uses 8 significant digits. I.e. A given floating point number can only give a certain number of significant digits before it overflows and causes an error.

Time delays are generally a function provided by the core functions of the language that interact with the system clock.

SeRoToNiN
01-10-2003, 01:41 AM
ozen, You're making sense dude! Other people are just being a bit pedantic. Lay off the newbies everyone, we were all there once! :x
You're delving into the world of 'Fixed' numbers. A lot of floating point calculations are not done with real floating point numbers. They are done with integers and 'bitwise operations' to give an integral part and a fractional part. The main purpose of this is speed (Floating point operations are much slower), but the same techniques can be used to extend the accuracy of calculations. You need to learn about the 'bit structure' of different variable types and other keywords I have put in quotation marks here. Also, you may have documentation on the 'FixedMul', 'FixedDiv' and 'FixedFromDouble' functions (part of Windows API). Note that these use a predefined 'FIXED' structure, but you can define your own and re-write the appropriate functions. Sounds easy?!? Well it probably won't be but at least you've been pointed in the right direction! :wink:
A couple of important things to note in case you didn't know: Numbers will 'wrap' when you exceed their bitwise capabilities. If you take the highest 32-bit integer possible, 0xFFFFFFFF (4,294,967,295) and add 1, you would get 0 as it 'wraps' back round to the start. This is true with all operations and, in some sense, with all data types.
Also note that the 'bit structures' of signed and unsigned integers is slightly different and also that types like 'int' and 'long' etc. are platform dependant. They may be 32-bit, 64-bit or anything else. Types like WORD and DWORD however are a fixed size (16-bit and 32-bit respectively).
Well, I hope I've guided you enough without just confusing you. If some of this makes no sense, it soon will once you start looking into it. Good luck with learning these structures and techniques and with whatever you need them for!