[Zephyr-devel] Using Math function in zephyr
ashish.shukla@corvi.com <ashish.shukla@...>
Hi Michael, After switching to new library, code compiles but it rounds off all the values to 0. -- Warm regards, Ashish Shukla Jr. Embedded Engineer Research & Development Please consider the environment before printing this e-mail or its attachments. Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi
On Fri, Dec 22, 2017 at 12:01 PM, Michael Hope <michaelh@...> wrote:
|
|
Michael Hope
Huh, interesting. It works for me in a test program: #include <zephyr.h> #include <misc/printk.h> #include <math.h> void main(void) { printf("round up: %f\n", round(1.9)); printf("round down: %f\n", round(3.1)); } """ ***** BOOTING ZEPHYR OS v1.10.99- - BUILD: Dec 21 2017 21:44:19 ***** round up: 2.000000 round down: 3.000000 """ This is on BOARD=qemu_cortex_m3 which uses the ARM soft float ABI. There's a chance that you've got a mix of hard float / soft float code but I thought the linker checked that.
|
|
ashish.shukla@corvi.com <ashish.shukla@...>
Hi, It doesn't seem to be working for me. Here's a test program #include <zephyr.h> #include <misc/printk.h> #include <math.h> void main(void) { printk("round up %d \n\r",round(5.7)); printk("round down %d \n\r",round(5.2)); } -- Warm regards, Ashish Shukla Jr. Embedded Engineer Research & Development Please consider the environment before printing this e-mail or its attachments. Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi
On Fri, Dec 22, 2017 at 1:02 PM, Michael Hope <michaelh@...> wrote:
|
|
Michael Hope
printk probably doesn't support floating point args. Give printf a try and make sure that printf float support is turned on under 'make menuconfig'.
|
|
ashish.shukla@corvi.com <ashish.shukla@...>
Michael, I'm a newbie in Zephyr, can you please tell the steps to be followed to turn on float support for printf. -- Warm regards, Ashish Shukla Jr. Embedded Engineer Research & Development Please consider the environment before printing this e-mail or its attachments. Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi
On Fri, Dec 22, 2017 at 2:39 PM, Michael Hope <michaelh@...> wrote:
|
|
Boie, Andrew P
Ø
printk("round up %d \n\r",round(5.7));
What output are you expecting? You are using %d. printk() doesn't support floating point.
Andrew
From: zephyr-users-bounces@... [mailto:zephyr-users-bounces@...]
On Behalf Of ashish.shukla@...
Sent: Friday, December 22, 2017 2:35 AM To: Michael Hope <michaelh@...> Cc: zephyr-users@...; zephyr-devel@... Subject: Re: [Zephyr-users] [Zephyr-devel] Using Math function in zephyr
Michael, I'm a newbie in Zephyr, can you please tell the steps to be followed to turn on float support for printf.
-- Warm regards, Jr. Embedded Engineer Research & Development
Please consider the environment before printing this e-mail or its attachments.
Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi
On Fri, Dec 22, 2017 at 2:39 PM, Michael Hope <michaelh@...> wrote:
|
|
Michael Hope
toggle quoted messageShow quoted text
|
|
ashish.shukla@corvi.com <ashish.shukla@...>
Thanks a lot Michael, for your efforts. It works now. -- Warm regards, Ashish Shukla Jr. Embedded Engineer Research & Development Please consider the environment before printing this e-mail or its attachments. Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi
On Sat, Dec 23, 2017 at 4:54 PM, Michael Hope <michaelh@...> wrote:
|
|