News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Floating point numbers

Started by bradyh30, March 31, 2011, 12:30:18 AM

Previous topic - Next topic

bradyh30

Quote from: raymond on May 03, 2011, 01:36:08 AM
Many questions now that we know what you are trying to accomplish.

1. Do you intend to use C# operations for parsing the expression?
2. Do you intend to use C# functions to convert the numerical values of the expression from ascii to binary (integers and floats) before performing the computations?
3. Can you use in-line assembly with C#?
4. Can you use assembly libraries with C#?


Hi Raymond I hear lots of good things about you. Also, thanks for your great FPU tutorial. Now to answer your questions:
1. Yes, we have already implemented this.
2. Yes, i am currently working on this.
3. Not that I know of.
4. I believe they have some but I have never used any.

qWord

Quote from: bradyh30 on May 04, 2011, 12:35:15 AM
4. I believe they have some but I have never used any.
c# allows to use any libray in form of an DLL.
FPU in a trice: SmplMath
It's that simple!

bradyh30

Yeah anyone can write a library for anything i guess.

So i will change my answer to I'm sure there is one out there but I have never used one.

raymond

From ypour first post:
QuoteI have a code that uses the FPU

Then:
Quote3. Can you use in-line assembly with C#?
3. Not that I know of.

What would be the kind of code where you can "use the FPU"?
As it is, I can only see inherent C# functions, to which you have no direct access, that would use the FPU to perform floating point computations.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

bradyh30

Quote from: raymond on May 04, 2011, 01:56:27 AM
What would be the kind of code where you can "use the FPU"?
As it is, I can only see inherent C# functions, to which you have no direct access, that would use the FPU to perform floating point computations.

Well the compiler is suppose to take floating point numbers. so within C# we are checking to see if it is float then adding, subtracting, ... is done withing the assembly itself. so that is where we are actually using the FPU.

Sorry if that didn't answer your question.

raymond

If you're expecting a possible mixture of floats and integers, I don't know if it's possible in C# but the easiest way may be to treat all input as floats even if it doesn't contain a decimal delimiter; or convert all integers immediately to floats before storage. If you're not concerned with precision and the available range is satisfactory, you can keep all of them in 32-bit variables. It's a lot easier to deal with a single type of data once you start computing the expression.

However, if the expression contains shifts or boolean operators, you would need to keep the input as integers!!! :eek Part of the fun of trying to create a compiler for a new programming language. ::)

As for displaying data without trailing 0's, you may simply have to parse the outgoing result to remove them before you display it.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

bradyh30

Quote from: raymond on May 04, 2011, 03:07:44 AM
If you're expecting a possible mixture of floats and integers, I don't know if it's possible in C# but the easiest way may be to treat all input as floats even if it doesn't contain a decimal delimiter; or convert all integers immediately to floats before storage. If you're not concerned with precision and the available range is satisfactory, you can keep all of them in 32-bit variables. It's a lot easier to deal with a single type of data once you start computing the expression.

However, if the expression contains shifts or boolean operators, you would need to keep the input as integers!!! :eek Part of the fun of trying to create a compiler for a new programming language. ::)

As for displaying data without trailing 0's, you may simply have to parse the outgoing result to remove them before you display it.

Thanks Raymond! I am going to do it the dirty way where i just loop through the number of floats I need and assign their values. I am not going to do anything else with this compiler when I am done with the class so it doesn't matter much to me. Sounds kind of bad I guess. I will deal with the output with trailing 0's when I finally get some output  :U