Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

C Serial.printing a long long

Status
Not open for further replies.

dr pepper

Well-Known Member
Most Helpful Member
I pinched this from somewhere:

Code:
void LL2Serial(long long ll)
{
  uint64_t xx = ll/1000000000ULL;
  if (xx >0) Serial.print((long)xx);
  Serial.println((long)(ll-xx*1000000000));
}

I use it to print a 64 bit value to the serial port, it works on evry value I've tried except for 10,000,000
Maths obviously isnt my thing, why doest this work?

Edit: Oh wait I sussedit, this is a frequency word word for a Si5351, the chip accepts 100'ths of a hz integer values, I was passing the conversion function above the hundredths of hz value, I didvided it by 100 first now it works Ok.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top