Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 264:d9593e0f1eea
Safer rounding (bug bb29)
author | JeanDo |
---|---|
date | Tue, 12 Apr 2011 00:36:23 +0200 |
parents | 9d4ab7c96885 |
children | ab8ce7de2b46 |
comparison
equal
deleted
inserted
replaced
263:27c9bb14b008 | 264:d9593e0f1eea |
---|---|
697 | 697 |
698 // Stops are needed ? | 698 // Stops are needed ? |
699 if( sim_lead_tissue_limit > pres_surface ) | 699 if( sim_lead_tissue_limit > pres_surface ) |
700 { | 700 { |
701 // Deepest stop, in meter (rounded up with a margin of 0.5m) | 701 // Deepest stop, in meter (rounded up with a margin of 0.5m) |
702 overlay unsigned char first_stop = 3 * (short)(0.99 + (sim_lead_tissue_limit - pres_surface) / 0.29955); | 702 overlay unsigned char first_stop = 3 * (short)(1.1667 + (sim_lead_tissue_limit - pres_surface) / 0.29955); |
703 assert( first_stop < 128 ); | 703 assert( first_stop < 128 ); |
704 | 704 |
705 #ifdef __DEBUG || defined(CROSS_COMPILE) | 705 #if defined(__DEBUG) || defined(CROSS_COMPILE) |
706 { | 706 { |
707 // Extra testing code to make sure the first_stop formula | 707 // Extra testing code to make sure the first_stop formula |
708 // and rounding provides correct depth: | 708 // and rounding provides correct depth: |
709 overlay float pres_stop = first_stop * 0.09985 // Meters to bar | 709 overlay float pres_stop = first_stop * 0.09985 // Meters to bar |
710 + pres_surface; | 710 + pres_surface; |