Main Content

Results for

goc3
goc3
Last activity on 7 Jun 2024

There are a host of problems on Cody that require manipulation of the digits of a number. Examples include summing the digits of a number, separating the number into its powers, and adding very large numbers together.
If you haven't come across this trick yet, you might want to write it down (or save it electronically):
digits = num2str(4207) - '0'
That code results in the following:
digits =
4 2 0 7
Now, summing the digits of the number is easy:
sum(digits)
ans =
13
Good morning,
I am trying to receive a long number in thingspeak and convert it to a string. However, when I receive it, it converts it to a number using scientific notation. I have tried changing the format to long g and others and was able to get rid of the scientific notation part.
After doing so, I have used commands such as num2str, mat2str, and compose to represent the number as a string, but I keep getting results that are off. An example is a message i am sending as:
field1=100630000553400000000
using an MQTT desktop client. However, when I receive it and print the result, I get:
0100630000553399992320
The numbers are close but the right one. Is there something I am missing?
Thanks in advance!
Pedro Ch.