Skip to content

cpatel@veejansh.com

Veejansh

Cloud++ Container++

  • Come Join Us
  • Know Us
  • Privacy Policy
  • Services
  • Tech Stack
  • Blog
  • Contact Us
  • Come Join Us
  • Know Us
  • Privacy Policy
  • Services
  • Tech Stack
  • Blog
  • Contact Us

Double Precision Rounding

  1. Home   »  
  2. Double Precision Rounding

Double Precision Rounding

2021 December 242021 December 24 adminC++, Programming

Uses my_double_greater_check from earlier article

DOUBLE MY_DOUBLE_ROUND( DOUBLE VAL, INT MULTIPLIER )
{
         DOUBLE VAL_ADJ = VAL * MULTIPLIER;
         IF ( MY_DOUBLE_GREATER_CHECK( VAL_ADJ FLOOR( VAL_ADJ ), 0.0 ) > 0 )
                      VAL = ROUND( VAL_ADJ ) / MULTIPLIER;
         RETURN VAL;
}

round and floor are C math library <math.h> functions.

E.g.

double rnd_val = my_double_round( 0.000998, 1000);

rnd_val will be 0.001

Continue reading

Post navigation

Previous: Thread Info in Java
Next: Double Precision Comparision

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Add time to prompt
  • Detached Process
  • Public IP
  • Traceroot
  • RW Shell

Recent Comments

No comments to show.

Archives

  • December 2021

Categories

  • Android
  • C++
  • Go
  • Java
  • Linux
  • Networking
  • PHP
  • Programming
  • Wordpress
Proudly powered by WordPress | Theme: goldly by reviewexchanger.