Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
978 Views

what is the data type of floating??

In my program i want to calculate some floating datas , but i dont know much about the data type about Altera. whether I can define them just like I did in VC. i want some material about such field.  

thanks a lot :) 

 

 

 

sunjie
0 Kudos
3 Replies
Altera_Forum
Honored Contributor I
240 Views

You can go into the megawizard and select the altfp_add_sub, altfp_div, or altfp_mult megafunction to do your floating point. I believe they let you select the floating point format. For example, if your c/c++ was using float, choose single precision. If your c/c++ was using double, choose double precision. 

 

Be careful with floating point. It produces MUCH larger and MUCH slower circuits than a fixed point. Most people go out of their way to avoid it. 

 

Good luck with your project.
Altera_Forum
Honored Contributor I
240 Views

 

--- Quote Start ---  

In my program i want to calculate some floating datas , but i dont know much about the data type about Altera. whether I can define them just like I did in VC. i want some material about such field.  

thanks a lot :) 

--- Quote End ---  

 

 

Wanting floating point "in your program" sounds as you you want it in C code running on the Nios processor. That should work just fine. The Nios compiler handles single and double precision FP. There's no floating point hardware, though, so it's all handled in library functions - if speed is an issue, you might need to check that it runs as fast as you want.
Altera_Forum
Honored Contributor I
240 Views

The Nios II compiler will provide you with IEEE754 floating point math for single and double precision. This means that round to nearest (floating point math isn't exact so this is the closest you can get) will be implemented and denormal support is not available (that's when a number becomes so small it might as well be zero). The floating point megawizard functions provide similar math support.

Reply