cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
chandrajit_pal
Explorer
Explorer
9,984 Views
Registered: ‎04-28-2010

displaying fractional value

hello Sir,

          I am using the edk based platform  for my project. I need to display a fraction value for example 12.3452 after some processing on the hyperterminal. However using floating point datatype in the C file is not solving my issue. It is only displaying the whole number part before the point i.e only 12. So how to solve it.    

Best Regards
Chandrajit
0 Kudos
Reply
7 Replies
muzaffer
Teacher
Teacher
9,970 Views
Registered: ‎03-31-2012

you mean you tried something like the following:

float f = 1.2345;
prinft("%f", f);
and got '1' only?
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Reply
chandrajit_pal
Explorer
Explorer
9,961 Views
Registered: ‎04-28-2010

yes sir..and not only that when I am using the format 2.4f also I am getting 1. when 1.9 is the desired result I am getting 1. i.e always the floor value.

Best Regards
Chandrajit
0 Kudos
Reply
gszakacs
Professor
Professor
9,950 Views
Registered: ‎08-14-2007

Can you post an example of your code where this happens?  Are you really using printf and not xil_printf?

-- Gabor
0 Kudos
Reply
chandrajit_pal
Explorer
Explorer
9,930 Views
Registered: ‎04-28-2010

Sir,

        I have attached my code herewith..This is simple an addition of two numbers say 1.2 ans 1.3 to produce 2.5 However when I am using xil_printf() I am getting the summation 2 instead of 2.5. However when I am using the function printf() instead of xil_printf() I am getting the error "microblaze_0_i_bram_ctrl_microblaze_0_d_bram_ctrl' overflowed by 592 bytes".

So what to do?

Best Regards
Chandrajit
0 Kudos
Reply
muzaffer
Teacher
Teacher
9,921 Views
Registered: ‎03-31-2012

xil_printf does not support floating point numbers.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Reply
chandrajit_pal
Explorer
Explorer
9,908 Views
Registered: ‎04-28-2010

yes sir that is true however when I am using only printf() then I am getting the error "microblaze_0_i_bram_ctrl_microblaze_0_d_bram_ctrl' overflowed by 592 bytes"..So any way out to this problem.

Thanks in advance

Best Regards
Chandrajit
0 Kudos
Reply
johnmcd
Xilinx Employee
Xilinx Employee
9,901 Views
Registered: ‎02-01-2008

printf() uses quit a bit more memory compared to xil_printf(). You need to increase the amount of BRAM available for your application.

0 Kudos
Reply